ORA-00904:“ DEPT_ID”:无效的标识符

时间:2019-09-05 12:48:20

标签: sql oracle foreign-keys

我检查了所有列名称,尝试删除该列并添加一个新列,但是我仍然收到此错误。我的SQL查询有问题吗?

  

ORA-00904:“ DEPT_ID”:无效的标识符

alter table Employ add foreign key (Dept_Id) references Department(Dept_ID);

1 个答案:

答案 0 :(得分:2)

类似这样的东西:

SQL> create table department (dept_id number primary key);

Table created.

SQL> create table employ (id         number primary key,
  2                       dept_id    number);

Table created.

SQL> alter table employ add constraint fk_ed foreign key (dept_id)
  2  references department (dept_id);

Table altered.

SQL>