QUESTION: Create a table named REP_CONTRACTS containing the columns listed in the following chart. A composite PRIMARY KEY constraint including the REP_ID, STORE_ID, and QUARTER columns should be assigned. In addition, FOREIGN KEY constraints should be assigned to both the REP_ID and STORE_ID columns.
create table REP_CONTRACTS
( STORE_ID number(5) not null
, NAME number(5)
, QUARTER char(3) not null
, REP_ID number(5) not null
);
alter table REP_CONTRACTS
add constraint FK_ID_STORE foreign key(STORE_ID)
reference REP_CONTRACTS(STORE_ID)
add constraint FK_ID_REP foreign key(REP_ID)
reference REP_CONTRACTS(REP_ID)
add constraint PK_REP_CONTRACTS primary key(STORE_ID, REP_ID, QUARTER)
reference REP_CONTRACTS(REP_ID, STORE_ID, QUARTER)
;
Even with out the "not null", I still get the same result. I have tried adding the primary and foreign keys with and without the references and constraint but I always keep getting this as a result.
Error starting at line : 618 in command -
alter table REP_CONTRACTS
add constraint FK_ID_STORE foreign key(STORE_ID)
reference REP_CONTRACTS(STORE_ID)
add constraint FK_ID_REP foreign key(REP_ID)
reference REP_CONTRACTS(REP_ID)
add constraint PK_REP_CONTRACTS primary key(STORE_ID,
REP_ID, QUARTER) reference REP_CONTRACTS(REP_ID, STORE_ID, QUARTER)
Error report -
ORA-00905: missing keyword
00905. 00000 - "missing keyword"
*Cause:
*Action: