Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: Oracle table creation script question

Re: Oracle table creation script question

From: Daniel A. Morgan <dmorgan_at_exesolutions.com>
Date: Tue, 12 Jun 2001 21:54:36 -0700
Message-ID: <3B26F20C.5EF5EA3B@exesolutions.com>

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 Tue Jun 12 2001 - 23:54:36 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US