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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Renaming a primary key

Re: Renaming a primary key

From: Richard Foote <richard.foote_at_bigpond.com>
Date: Sun, 13 Oct 2002 23:38:15 +1000
Message-ID: <Cveq9.51943$g9.151245@newsfeeds.bigpond.com>


Note that renaming a column/constraint directly was only introduced in 9i Rel 2.

Cheers

Richard
"Marc Blum" <marc_at_marcblum.de> wrote in message news:bnsiqu8q1eecq15lgd28gnvl9jhdpgopu0_at_4ax.com...
> On Fri, 11 Oct 2002 09:09:45 -0400, P B <pbeliveau_at_avcorp.com> wrote:
>
> >I have a set of table that look like this:
> >
> >One table with a P/N as a primary key and within some reference to
> >other P/N
> >
> >One table with a P/N and a SPEC as a primary key (P/N referencing to
> >the other table of course)
> >
> >And finally a bunch of other table referencing to the second table
> >(P/N & SPEC)
> >
> >Question: How do I proceed to rename the primary key of the first
> >table and cascade the change to all other table ?
> >
> >Thanks
>
> SQL> SELECT banner
> 2 FROM v$version;
>
> BANNER
> --------------------------------------------------------------
> Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
> PL/SQL Release 9.2.0.1.0 - Production
> CORE 9.2.0.1.0 Production
> TNS for 32-bit Windows: Version 9.2.0.1.0 - Production
> NLSRTL Version 9.2.0.1.0 - Production
>
> SQL>
> SQL> DROP TABLE t;
>
> Tabelle wurde gelöscht.
>
> SQL>
> SQL> CREATE TABLE t
> 2 (v VARCHAR2(1));
>
> Tabelle wurde angelegt.
>
> SQL>
> SQL> ALTER TABLE t
> 2 ADD CONSTRAINT pk
> 3 PRIMARY KEY (v);
>
> Tabelle wurde geändert.
>
> SQL>
> SQL> SELECT constraint_name
> 2 FROM user_constraints
> 3 WHERE table_name = 'T';
>
> CONSTRAINT_NAME
> ------------------------------
> PK
>
> SQL>
> SQL> ALTER TABLE t
> 2 RENAME CONSTRAINT pk TO pk_2;
>
> Tabelle wurde geändert.
>
> SQL>
> SQL> SELECT constraint_name
> 2 FROM user_constraints
> 3 WHERE table_name = 'T';
>
> CONSTRAINT_NAME
> ------------------------------
> PK_2
>
> SQL>
> SQL>
>
> Marc Blum
> mailto:marc_at_marcblum.de
> http://www.marcblum.de
Received on Sun Oct 13 2002 - 08:38:15 CDT

Original text of this message

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