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: Naming FKs

Re: Naming FKs

From: Christopher Beck <clbeck_at_us.oracle.com>
Date: Fri, 28 Aug 1998 14:13:44 GMT
Message-ID: <35e6b3eb.4337076@dcsun4.us.oracle.com>


On Thu, 27 Aug 1998 17:35:25 -0700, "Doug Stone" <Doug_Stone_at_compuserve.com> wrote:

>Does anyone know if it is possible to name FKs?
>

While creating a table you can do the following assuming the table BAR exists and is defined as

create table BAR
(
  id number primary key
);

Then you can...

create table FOO
(
  id number constraint foo_pk primary key,   fid number constraint foo_2_bar_fk references bar(id) );

create table FOO
(
  id number,
  fid number,
  constraint foo_pk primary key (id),
  constraint foo_2_bar_fk foreign key (fid) references bar (id) );

Or if the table already exists, you can add the foreign key using

alter table foo add constraint foo_2_bar_fk   foreign key (fid) references bar (id);

hopes this helps.

chris.

> All the FKs in my DB are named by Oracle.
>
>Thank you,
>Doug
>
Received on Fri Aug 28 1998 - 09:13:44 CDT

Original text of this message

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