【发布时间】:2020-11-14 17:46:02
【问题描述】:
我写了这段代码,但我不知道为什么会出错
错误报告 - ORA-00903: 无效的表名
Create table downloads
(
download_id int Primary Key NOT NULL,
User_id int,
download_date date,
filename Varchar(20),
product_id int,
CONSTRAINT fk_column FOREIGN KEY (USER_id) REFERENCES user (user_id),
FOREIGN KEY (product_id) REFERENCES products(product_id)
);
【问题讨论】:
-
user不能用作表名,除非引用(例如"user")作为保留关键字。顺便说一句,在Primary Key旁边使用NOT NULL是多余的。 -
另外,请注意在 Oracle 中引用表、列或其他对象名称通常被认为是一种不好的做法,因为在引用该对象时您必须始终使用引号。首先避免保留关键字要好得多。