RE: Foreign key constraints with constant values?

  • From: "Powell, Mark" <mark.powell2@xxxxxx>
  • To: "oracle-l@xxxxxxxxxxxxx" <oracle-l@xxxxxxxxxxxxx>
  • Date: Mon, 25 Oct 2010 13:28:27 +0000

A FK must be defined on the PK or UK of the referenced table so if the 
reference table PK is made up of two columns even though one column provides 
unique values your FK must reference both columns.

 

-----Original Message-----
From: oracle-l-bounce@xxxxxxxxxxxxx [mailto:oracle-l-bounce@xxxxxxxxxxxxx] On 
Behalf Of Octavian Rasnita
Sent: Saturday, October 23, 2010 2:14 PM
To: oracle-l@xxxxxxxxxxxxx
Subject: Foreign key constraints with constant values?

Hi,

I have made the following table:

create table client(
id integer not null,
name varchar2(200),
type1 integer not null,
type2 integer not null,
foreign key (type1, type2) references constants(id, type) );

It works fine, but the column type2 contains a unique value in all the records.
Is it possible to drop that column and use the constant value from it in the 
foreign key reference directly?

I have tried the following, but it gave an error:

create table client(
id integer not null,
name varchar2(200),
type1 integer not null,
foreign key (type1, 1) references constants(id, type) );

Thanks.

Octavian

--
//www.freelists.org/webpage/oracle-l


--
//www.freelists.org/webpage/oracle-l


Other related posts: