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: Stephen Bell <stephen.bell_at_cgi.ca>
Date: Wed, 13 Jun 2001 10:37:05 -0400
Message-ID: <3B277A91.D48EC600@cgi.ca>

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.

  1. Ability to name the constraint - that's available in the CREATE syntax - am I misinterpreting? and
  2. Defining default storage and tablespace parameters - are you referring to the index itself on the PK?

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

Original text of this message

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