Anupam Alur
Anupam Alur

Reputation: 13

Where am I going wrong here? Keep getting the error "cannot add Foreign Key Constraint"

Create table Emp 
(
     eid integer, 
     name varchar(100),
     age integer, 
     salary real, 
     Primary Key(eid)
);

Create table Dept 
(
     did integer,
     budget Real,
     managerid integer, 
     Primary Key(did)
);

Create table Works 
(
    eid integer,
    did integer, 
    pct_time integer, 
    Foreign key (eid) References Emp
);

Upvotes: 0

Views: 32

Answers (1)

dstudeba
dstudeba

Reputation: 9038

I think you forgot to mention what column it references.

Try:

...Foreign key (eid) References Emp (eid));

Upvotes: 1

Related Questions