0

I used to create composite index for my Oracle table with the following script.

CREATE INDEX index_name ON my_table (column1,column2,column3) TABLESPACE tablespace_name;

When I tried the same in DB2, got some errors at tablespace and I tried using the following script simply,

CREATE INDEX index_name ON my_table (column1,column2,column3);

Is this fine in DB2? As I am new to DB2 and no syntax found when searched for a composite index in DB2, not sure about this. Need advice.

1 Answer 1

1

For the CREATE INDEX documentation, you can check the InfoCenter: http://pic.dhe.ibm.com/infocenter/db2luw/v10r5/topic/com.ibm.db2.luw.sql.ref.doc/doc/r0000919.html

The DB2 CREATE INDEX sentence you provided is correct. Remember that in DB2, you do not provide the tablespace at index creation. The tablespace for indexes is specified when you create the table

CREATE TABLE XX
 (
 ...
 )
IN ts_table
INDEX IN ts_indexes

For more information about the create table, please take a look at this: http://pic.dhe.ibm.com/infocenter/db2luw/v10r5/topic/com.ibm.db2.luw.sql.ref.doc/doc/r0000927.html

Sign up to request clarification or add additional context in comments.

3 Comments

This is a platform specific answer for DB2 LUW. For those who have DB2 for i see pic.dhe.ibm.com/infocenter/iseries/v7r1m0/…
@WarrenT we should ask the platform, and re-tag the questions. I found that there is a tag called db2400, I think it should be called db2i. Also, I did not see any tag for DB2 for zOS.
Also note that you can specify a tablespace in the CREATE INDEX statement if you are using range partitioned tables. Some have noted that you can create a table with a single range partition specifically so that you can create each index in a separate tablespace.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.