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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- SAP索引重組技術索引
- 索引組織表上建立BITMAP索引(三)索引
- 索引組織表上建立BITMAP索引(二)索引
- 索引組織表上建立BITMAP索引(一)索引
- mongodb 重複建立索引不報錯MongoDB索引
- sqlserver索引重建和索引重組的區別和操作方法SQLServer索引
- DB2_多維叢集表索引延遲清理DB2索引
- [20151008]索引組織表上建立BITMAP索引.txt索引
- ElasticSearch建立索引Elasticsearch索引
- 索引與null(二):組合索引索引Null
- mysql組合索引,abc索引命中MySql索引
- Oracle堆組織表的索引和索引組織表Oracle索引
- mysql建立字首索引MySql索引
- mongodb建立索引和刪除索引和背景索引backgroundMongoDB索引
- oracle 索引組織表Oracle索引
- DB2_安全DB2
- mysql 建立索引的方法--建立檢視MySql索引
- 【Oracle】-【建立索引】-建立索引的操作原理與一些體會Oracle索引
- MySQL建立索引、修改索引、刪除索引的命令語句MySql索引
- postgresql怎麼建立索引SQL索引
- Lucene建立索引流程索引
- MySQL建立複合索引MySql索引
- SqlServer 建立全文索引SQLServer索引
- MySQL 組合索引不生效MySql索引
- ORACLE 組合索引 使用分析Oracle索引
- Oracle 索引組織表(IOT)Oracle索引
- DB2_建庫DB2
- DB2_審計DB2
- MySQL學習筆記:組合索引-索引下推MySql筆記索引
- MySQL單列索引和組合索引的區別MySql索引
- Mysql索引的使用-組合索引+跳躍條件MySql索引
- ElasticSearch分片互動過程(建立索引、刪除索引、查詢索引)Elasticsearch索引
- Oracle如何建立B樹索引Oracle索引
- 資料庫之建立索引資料庫索引
- mysql建立索引和檢視MySql索引
- Oracle大表快速建立索引Oracle索引
- oracle 索引的建立與管理Oracle索引
- 建立索引——提高SQL Server效能索引SQLServer