Question

create table Employee(E_ID char(15) PRIMARY KEY,name char(15),salary char(12), CONSTRAINT a_I FOREIGN KEY(L_ID) REFERENCES Department(D_id), constraint r_N FOREIGN KEY(M_ID)REFERENCES manger(M_ID))

Was it helpful?

Solution

You don't have columns in this table called l_id or m_id, so I'm guessing it's reporting that in the error you haven't shown. You have to define the columns explicitly, before using them as foreign key references. I'm guessing they are both numbers, but use the appropriate data types from the other tables if not:

create table Employee(E_ID char(15) PRIMARY KEY,
  name char(15),
  salary char(12),
  l_id number,
  m_id number,
  CONSTRAINT a_I FOREIGN KEY(L_ID) REFERENCES Department(D_id), 
  constraint r_N FOREIGN KEY(M_ID)REFERENCES manger(M_ID)
)

This is shown in the documentation, including the foreign key example.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top