Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> column_constraint_clause
Hi,
I was wondering why I get an error with this create table statement:
create table country
(
code varchar2(5) primary key, cont varchar2(5) foreign key references continent (code), name varchar2(30) not null
The error I get is:
cont varchar2(5) foreign key references continent (code),
*
I'm trying to make cont a foreign key which references the code column
of the continent table.
Is 'foreign key references continent (code),' not a valid
column_constraint_clause' (as described on p.379 of the Oracle
DB Administration book by O'Reilly). Is it in the wrong place? I noticed
that in the $ORACLE_HOME/rdbms/demo/summit2.sql script, foreign keys are
added using the ALTER TABLE command after the tables have been created.
Why is this? What is the usual way of specifying foreign keys?
Thanks,
![]() |
![]() |