Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Oracle table creation script question
TC wrote:
> Hi,
>
> I have a table creation script in hand (written by another guy), and
> I'm trying to figure out why exactly the primary keys are created as
> they are:
>
> For each table, the following sequence of steps is performed:
>
> 1) The table is defined, except that no column is designated as the
> PK.
> 2) A unique index is created on a column (the PK-designate).
> 3) An ALTER TABLE ADD CONSTRAINT command is issued to add the PK
> constraint on that column.
>
> Can someone comment on the benefits of doing things this way? Full
> storage parameters are included in steps 1 & 2, if that helps.
>
> Thanks for any assistance,
> Tom C.
There is no specific advantage in creating the unique index and primary key constraint as separate steps ... but there is a definite advantage is not doing primary key creation as part of creating the table.
The main reasons are:
1. Ability to name the constraint 2. Ability to define storage and tablespace parameters 3. Ease of dropping and rebuilding the primary key at a later date asthe DDL is independent of the table creation
Daniel A. Morgan Received on Tue Jun 12 2001 - 23:54:36 CDT
![]() |
![]() |