Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: column_constraint_clause
Looks like you are trying to add a TABLE level Constraint onto a Column ..
Try
create table country
(
code varchar2(5) primary key, cont varchar2(5) constraint cont_fk references continent(code), .....
or
create table country
(
code varchar2(5) primary key, cont varchar2(5) , name varchar2(30) not null
Both should work fine..
Hope this helps..
-Thiru
kev wrote:
> 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),
> *
> ORA-00907: missing right parenthesis
>
> 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,
>
> - Kev
Received on Mon Aug 02 1999 - 13:12:39 CDT
![]() |
![]() |