database - "Missing Keyword" When creating a table in Oracle SQL Developer -


i keep getting

"sql error: ora - 00905: missing keyword" in "create table"

portions of code shown below:

    create table orders (     received char(9),     shipped char(9),     foreign key (ono), references odetails (ono),     foreign key (cno), references customers (cno),     foreign key (eno), references employee (eno),      primary key (ono, cno, eno)     );      create table zipcodes (     zip char(5) not null,     city char(20),     foreign key (zip), references customers (zip),     primary key (zip)      ); 

however, wrote code in same worksheet , did not errors ever:

    create table odetails (     ono char(4) not null,     pno char(5) not null,     qty char(1),     foreign key (pno), references parts (pno),     primary key (ono)      ); 

can me identify causing error?

1) not use comma

2) define columns

create table orders (     received char(9),     shipped char(9),     ono int not null ,   -- missing columns (add datatype need)     cno int not null,     eno int not null,     foreign key (ono) references odetails (ono),  -- here no comma inside     foreign key (cno) references customers (cno),     foreign key (eno) references employee (eno),      primary key (ono, cno, eno)     );  create table zipcodes (     zip char(5) not null,     city char(20),     foreign key (zip) references customers (zip),     primary key (zip)      ); 

consider using varchar2 datatype instead of char.

you use inline syntax like:

create table orders (   ...    ono int not null references odetails (ono)   ... ); 

or add explicit constraint name:

create table orders (       ...        ono int not null,       ...       constraint fk_orders_odetails_ono  foreign key (ono) references odetails (ono),       ... ); 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -