Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Naming FKs
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