Hi,
I am trying to code my database [Oracle], but am coming across a problem that I cannot figure out. The code below gives the following error
Table dropped.
Table created.
Table created.
CONSTRAINT ACCOM_res_id_fk FOREIGN KEY (res_id) REFERENCES RESORT (res_id
*
ERROR at line 11:
ORA-00904: "RES_ID": invalid identifier
I have tried all I know and probably it is something simple but I cannot spot why I am getting this error. The table is created that provides the foreign key but it does not seem
to recognize it . I have made it upper case / lower case / renamed VARCHAR2 to CHAR/ removed the constraint on the RESORT primary key/taking out underscores... but the same error crops up.
The Code:
Drop TABLE accom;
Drop TABLE resort;
CREATE TABLE RESORT
(
res_id NUMBER (10) NOT NULL,
res_name VARCHAR2 (20) NOT NULL,
res_country VARCHAR2 (20) NOT NULL,
res_elav NUMBER (7),
res_numlifts NUMBER (3),
res_num_grn NUMBER (3),
res_num_red NUMBER (3),
res_num_blk NUMBER (3),
CONSTRAINT RESORT_res_id_pk PRIMARY KEY (res_id)
) ;
CREATE TABLE ACCOM
(
accom_id NUMBER(10) NOT NULL,
accom_name VARCHAR2 (20) NOT NULL,
accom_addr VARCHAR2 (100) NOT NULL,
accom_cap NUMBER(4) NOT NULL,
accom_avail NUMBER(4) NOT NULL,
accom_disc NUMBER(3) NOT NULL,
accom_rate NUMBER(3) NOT NULL,
CONSTRAINT ACCOM_accom_id_pk PRIMARY KEY (accom_id),
CONSTRAINT ACCOM_res_id_fk FOREIGN KEY (res_id) REFERENCES RESORT (res_id)
);
thanks for any help
Eoin
I am trying to code my database [Oracle], but am coming across a problem that I cannot figure out. The code below gives the following error
Table dropped.
Table created.
Table created.
CONSTRAINT ACCOM_res_id_fk FOREIGN KEY (res_id) REFERENCES RESORT (res_id
*
ERROR at line 11:
ORA-00904: "RES_ID": invalid identifier
I have tried all I know and probably it is something simple but I cannot spot why I am getting this error. The table is created that provides the foreign key but it does not seem
to recognize it . I have made it upper case / lower case / renamed VARCHAR2 to CHAR/ removed the constraint on the RESORT primary key/taking out underscores... but the same error crops up.
The Code:
Drop TABLE accom;
Drop TABLE resort;
CREATE TABLE RESORT
(
res_id NUMBER (10) NOT NULL,
res_name VARCHAR2 (20) NOT NULL,
res_country VARCHAR2 (20) NOT NULL,
res_elav NUMBER (7),
res_numlifts NUMBER (3),
res_num_grn NUMBER (3),
res_num_red NUMBER (3),
res_num_blk NUMBER (3),
CONSTRAINT RESORT_res_id_pk PRIMARY KEY (res_id)
) ;
CREATE TABLE ACCOM
(
accom_id NUMBER(10) NOT NULL,
accom_name VARCHAR2 (20) NOT NULL,
accom_addr VARCHAR2 (100) NOT NULL,
accom_cap NUMBER(4) NOT NULL,
accom_avail NUMBER(4) NOT NULL,
accom_disc NUMBER(3) NOT NULL,
accom_rate NUMBER(3) NOT NULL,
CONSTRAINT ACCOM_accom_id_pk PRIMARY KEY (accom_id),
CONSTRAINT ACCOM_res_id_fk FOREIGN KEY (res_id) REFERENCES RESORT (res_id)
);
thanks for any help
Eoin