Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: column_constraint_clause

Re: column_constraint_clause

From: tmgn <tmgn_at_excite.com>
Date: Mon, 02 Aug 1999 14:12:39 -0400
Message-ID: <37A5DF97.CB01F753@excite.com>


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

  constraint cont_fk foreign key(cont) references continent(code) );

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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US