Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Renaming a primary key
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
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
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
SQL>
SQL>
Marc Blum
mailto:marc_at_marcblum.de
http://www.marcblum.de
Received on Sun Oct 13 2002 - 08:19:57 CDT
![]() |
![]() |