I am using Oracle Express Eddition 10g.
The DDL below throws a DB error on the line with “REFERENCES TABLE_A_PK”
“SQL Error: ORA-00942: table or view does not exist”
CREATE TABLE TABLE_A (
COLUMN_A NUMBER,
COLUMN_B NUMBER,
COLUMN_C NUMBER,
COLUMN_D NUMBER,
CONSTRAINT TABLE_A_PK
PRIMARY KEY (COLUMN_A, COLUMN_B)
)
CREATE TABLE TABLE_B (
COLUMN_A NUMBER,
COLUMN_B NUMBER,
COLUMN_Y NUMBER,
COLUMN_Z NUMBER,
CONSTRAINT TABLE_A_FK
FOREIGN KEY (COLUMN_A, COLUMN_B)
REFERENCES TABLE_A_PK
)
Can I use a named constrain as a foreign key reference? If so how?
You don’t specify the name of the key you are referencing, you specify the columns so, no, you can’t reference the name of the constraint. You need to specify something like