DB2_建立重組索引
目的:
測試DB2建立重組索引,本指令碼摘錄自DB2安裝目錄/admin_scripts/tbonlineinx.db2。
版本:Windows DB2 Express-C V9.7
操作步驟:
使用"db2cmd db2 -t"進入互動模式,執行後續操作。
-- connect to sample database
CONNECT TO SAMPLE;
1,建立索引
-- create an index on a table with different levels of access to the table
-- like read-write, read-only, no access
-- create an online index with read-write access to the table
CREATE INDEX index1 ON employee (lastname ASC);
-- drop the index
DROP INDEX index1;
-- create an index on a table while allowing only read access to it
LOCK TABLE employee IN SHARE MODE;
CREATE INDEX index1 ON employee (lastname ASC);
-- drop the index
DROP INDEX index1;
-- create an online index allowing no access to the table
LOCK TABLE employee IN EXCLUSIVE MODE;
CREATE INDEX index1 ON employee (lastname ASC);
-- reorg online index on the table
2,重組索引
-- reorganize the indexes on the table allowing read-write
REORG INDEXES ALL FOR TABLE employee
ALLOW WRITE ACCESS
ON ALL DBPARTITIONNUMS;
-- reorganize the indexes on the table allowing read-only
REORG INDEXES ALL FOR TABLE employee
ALLOW READ ACCESS
ON ALL DBPARTITIONNUMS;
-- reorganize the indexes on the table allowing no access
REORG INDEXES ALL FOR TABLE employee
ALLOW NO ACCESS
ON ALL DBPARTITIONNUMS;
-- drop the index
DROP INDEX index1;
3,建立超常列索引
-- create bufferpool with 32K pagesize
CREATE BUFFERPOOL bupl32k SIZE 500 PAGESIZE 32K;
-- create tablespace using above created bufferpool
CREATE TABLESPACE tbsp32k
PAGESIZE 32k
MANAGED BY DATABASE
USING (FILE 'tbsp32k' 500)
BUFFERPOOL bupl32k;
-- create table with large coloumn size.
CREATE TABLE inventory_ident (dept INTEGER,
serial_numbers VARCHAR(8190) NOT NULL)
IN tbsp32k;
-- create a system temporary table space with 32K pages.
-- When the INDEXSORT database configuration parameter is set to Yes
-- (which is the default), then that data is sorted before it is passed
-- to index manager. If sort heap is big enough for the amount of data
-- being sorted, the sort will occur entirely in memory. However, just
-- in case we need to spill to disk, DB2 will ensure that there is a
-- system temporary tablespace with a large enough page size to spill to.
CREATE SYSTEM TEMPORARY TABLESPACE tmptbsp32k
PAGESIZE 32K
MANAGED BY SYSTEM
USING ('tmp_tbsp_32k')
EXTENTSIZE 2
BUFFERPOOL bupl32k;
-- create an index on the serial_numbers column
-- The upper bound for an index key length is variable based on
-- page size. The maximum length of an index key part can be:
-- 1024 bytes for 1K page size,
-- 2048 bytes for 8K page size,
-- 4096 bytes for 16K page size,
-- 8192 bytes for 32K page size,
-- and, the index name can be upto 128 char
CREATE INDEX inventory_serial_number_index_ident
ON inventory_ident (serial_numbers);
-- perform. cleanup
DROP INDEX inventory_serial_number_index_ident;
DROP TABLE inventory_ident;
DROP TABLESPACE tmptbsp32k;
DROP TABLESPACE tbsp32k;
DROP BUFFERPOOL bupl32k;
-- disconnect from the database
CONNECT RESET;
TERMINATE;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/18922393/viewspace-702298/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- sqlserver索引重建和索引重組的區別和操作方法SQLServer索引
- Hive建立索引Hive索引
- DocumentDB 建立索引索引
- DB2_簡單命令列DB2命令列
- DB2_更新SQL欄位DB2SQL
- mysql建立字首索引MySql索引
- mongodb建立索引和刪除索引和背景索引backgroundMongoDB索引
- mysql組合索引,abc索引命中MySql索引
- 索引與null(二):組合索引索引Null
- MySQL索引建立原則MySql索引
- Lucene建立索引流程索引
- postgresql怎麼建立索引SQL索引
- ElasticSearch分片互動過程(建立索引、刪除索引、查詢索引)Elasticsearch索引
- mysql建立索引和檢視MySql索引
- Oracle大表快速建立索引Oracle索引
- Oracle如何建立B樹索引Oracle索引
- 資料庫之建立索引資料庫索引
- 建立索引的優劣勢索引
- 【Mongo】MongoDB索引管理-索引的建立、檢視、刪除MongoDB索引
- mysql的組合索引MySql索引
- 索引設計(組合索引適用場景)索引
- 建立索引後,速度變快原因?以及索引失效總結索引
- MySQL如何建立一個好索引?建立索引的5條建議【宇哥帶你玩轉MySQL 索引篇(三)】MySql索引
- python建立elasticsearch索引的探討PythonElasticsearch索引
- 如何清除建立失敗的索引索引
- elasticsearch(三)----索引建立與刪除Elasticsearch索引
- [20201110]oracle建立索引nosrt.txtOracle索引
- mongodb資料庫如何建立索引?MongoDB資料庫索引
- Mysql索引的建立與刪除MySql索引
- MySQL學習筆記:組合索引-索引下推MySql筆記索引
- MySQL 組合索引不生效MySql索引
- MySQL建立表的時候建立聯合索引的方法MySql索引
- 聯合索引和多個單列索引使用中的索引命中情況及索引建立原則索引
- mysql 建立和刪除聯合索引MySql索引
- 用SQL建立索引的方法步驟SQL索引
- SQLServer索引優化(3):對於建組合索引的要求SQLServer索引優化
- LOB欄位相關概念(自動建立LOB索引段和重建索引方法)索引
- windows10系統建立索引的方法Windows索引
- Elasticsearch6.2.4-利用head外掛建立索引Elasticsearch索引