1. How to know whether an index is a partitioned index or a non-partitioned index.
2. Must have a non-partitioned index on the partition table.
Sycat.indexes and Syscat.indexpartitions 1. Create table 1). First execute the following command with root privileges
TOUCH/TMP/TBSP01
touch/tmp/tbsp02
touch/tmp/tbsp03
chown ba5oltp1/tmp/tbsp*
2). Create a partition to use the Tablespace
[BA5OLTP1@DB2CLS02 ~]$ DB2 "Create Tablespace TBSP01 managed by database using (FILE '/tmp/tbsp01 ')"
db20000i
the SQL Command completed successfully.
[BA5OLTP1@DB2CLS02 ~]$ DB2 "Create Tablespace TBSP02 managed by database using (FILE '/tmp/tbsp02 ')"
DB20000I
the SQL Command completed successfully.
[BA5OLTP1@DB2CLS02 ~]$ DB2 "Create Tablespace TBSP03 managed by database using (FILE '/tmp/tbsp03 ')"
Db20000i
the SQL Command completed successfully.
3). Create a test table
DB2 "CREATE TABLE emp_tooo (emp_no int,name varchar (), sex INT) partition by range (EMP_NO)
(starting 0 ending 100000 I N Tbsp01,
starting 100001 ending 200000 in tbsp02,
starting 200001 ending 300000 in tbsp03) "
4). Create an index
DB2 "CREATE INDEX pk_too_id on emp_tooo (emp_no) not partitioned"
DB2 "CREATE INDEX Uni_too_name on emp_tooo (name) par Titioned "
5). Query Syscat.indexes syscat.indexpartitions
[Ba5oltp1@db2cls02 ~]$ DB2 "select varchar (indname,30), Iid,datapartitionid from syscat.indexpartitions where Tabname= ' Emp_tooo ' "
1 IID datapartitionid
---------------------------------------------------
uni_ Too_name 2 0
uni_too_name 2 1
uni_too_name 2 2
3 record (s) selected.
[Ba5oltp1@db2cls02 ~]$ DB2 "select varchar (indname,30) from syscat.indexes where tabname= ' emp_tooo '"
1
----- -------------------------
pk_too_id
uni_too_name
2 record (s) selected.
Conclusion
Conclusion 1:
Each index in the indexes view corresponds to one piece of data, whether it is a partitioned index or a non-partitioned index;
Indexpartitions contains only the partition index;