DB2 Partition Table Related ~

Source: Internet
Author: User
Tags create index db2 touch

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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.