ORA-00904: "CITYCODE": invalid identifier in CREATE TABLE -


so, i'm not sql , trying jsut great 2 tables. 1 called city pk of citycode, , warehouse, uses citycode fk. , i'm not surprised if wrong.

these 2 create requests:

create table city ( citycode        number(2), cityname        varchar2(30), population      number(7), primary key     (citycode) ); create table warehouse ( whid            number(2), address         varchar2(30), capacity        number(7), capacity_used   number(7), mgrname         varchar2(30), mgrgender       varchar2(1), primary key     (whid), foreign key     (citycode) references city );   

then when run these in isql error ora-00904: "citycode": invalid identifier. can find error select statements.

thanks :)

you need create column references other table. like

create table city ( citycode        number(2), cityname        varchar2(30), population      number(7), constraint city_pk                 primary key     (citycode) );  create table warehouse ( whid            number(2), address         varchar2(30), capacity        number(7), capacity_used   number(7), mgrname         varchar2(30), mgrgender       varchar2(1), citycode        number(2), <-- note 1 constraint warehouse_pk                 primary key     (whid), constraint warehouse_fk                 foreign key     (citycode)                 references city (citycode) );   

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -