Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Creating primary key faster

User_OCZ1TMay 2 2020 — edited May 3 2020

Hi, We are using version 11 .2.0.4 of oracle exadata. We have some dynamic script as part of which few of the stage tables which will hold ~100's of millions of rows and primary key needs to be created to do the partition exchange with main partition table(which holds local primary key/indexes). So to handle this , we are planning to create indexes first in parallel on the stage table. And we want to add primary key constraints to it after the indexes created to make things faster. So want to understand, if we don't pass the index name explicitly, then does below syntax will automatically use the already created index(on same set of columns) to add the primary key constraints? or it won't and Oracle will again scan all those data to create the PK and so will take the same amount of time which it would have taken for creating index in serial fashion?

alter table tab1 add constraint tab1_k primary key(id) using index; -- Without explicitly mentioning what index to use.

This post has been answered by L. Fernigrini on May 2 2020
Jump to Answer
Comments
Post Details
Added on May 2 2020
3 comments
1,028 views