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
Post a Comment