Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Oracle table creation script question
Hi Daniel,
I was involved in this exact conversation yesterday so your post here is of
interest..
I understand the third reason for seperate PK DDL, but #1 and 2 I'm unclear
on.
Any thoughts are appreciated.
Steve
"Daniel A. Morgan" wrote:
> 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 as
> the DDL is independent of the table creation
>
> Daniel A. Morgan
Received on Wed Jun 13 2001 - 09:37:05 CDT