Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How to create primary key/foreign key?
On Thu, 13 Aug 1998 12:07:56 -0500, paulsian_at_sprintmail.com (Paul
Sian) wrote:
>I have a table where I need to create a primary key and a foreign key =
for
>the same column. How do I do this?
>Thanks
Hi Paul,
if you want to use named constraints, use:
ALTER TABLE <your_table> ADD (CONSTRAINT <your_pk_name> PRIMARY KEY <col_1, ..., col_n>);
You could add a 'USING INDEX' clause to have control over storage parameters. Check the Oracle Server SQL Reference Guide for details.
For the foreign key, use:
ALTER TABLE <your_table> ADD (CONSTRAINT <your_fk_name> FOREIGN KEY <col_1, ..., col_n>
HTH
Peter
--
Peter Schneider
peter.schneider_at_okay.net
Received on Thu Aug 13 1998 - 14:40:17 CDT
![]() |
![]() |