SQL:缺少关键字、外键
我正在尝试创建一个带有外键的表,但我不断收到缺少关键字的错误。有关可能导致问题的原因的任何标题吗?
Create table CAR
(vin varchar2(7),
SaleDate date,
SalePrice number (7,2),
Balance_due number (7, 2),
date_bought date,
miles number(6),
CONSTRAINT pkcar PRIMARY KEY(vin),
CONSTRAINT fkcar1 FOREIGN KEY(BrName) REFRENCES BRANCH,
CONSTRAINT fkcar4 FOREIGN KEY(CarTypeCode) REFRENCES CARTYPE,
CONSTRAINT fkcar2 FOREIGN KEY(BuyerId) REFRENCES CUSTOMER,
CONSTRAINT fkcar3 FOREIGN KEY(SellerId) REFRENCES CUSTOMER);
错误如下: 第 9 行错误:ORA-00905:缺少关键字
我已经创建了其他表(BRANCH、CARTYPE、CUSTOMER)并将其主键设置为(BrName、CarTypeCode、CustId)。
I am trying to create a table with a foreign key, but I keep on getting a missing keyword error. Any headers on what may be causing the problem?
Create table CAR
(vin varchar2(7),
SaleDate date,
SalePrice number (7,2),
Balance_due number (7, 2),
date_bought date,
miles number(6),
CONSTRAINT pkcar PRIMARY KEY(vin),
CONSTRAINT fkcar1 FOREIGN KEY(BrName) REFRENCES BRANCH,
CONSTRAINT fkcar4 FOREIGN KEY(CarTypeCode) REFRENCES CARTYPE,
CONSTRAINT fkcar2 FOREIGN KEY(BuyerId) REFRENCES CUSTOMER,
CONSTRAINT fkcar3 FOREIGN KEY(SellerId) REFRENCES CUSTOMER);
The error reads:
Error at line 9: ORA-00905:missing keyword
I have already created the other tables (BRANCH, CARTYPE, CUSTOMER) and set their primary keys as (BrName, CarTypeCode, CustId).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
拼写为REFRENCES
REFERENCES
is spelledREFRENCES
REFERENCES
REFRENCES 应该是我猜的引用..并且您没有指定父表 CONSTRAINT fk_column 的列
外键(列 1、列 2、... 列_n)
引用父表(列 1、列 2、... 列_n)
REFRENCES should be references i guess .. and you are not specifying the column of the parent table CONSTRAINT fk_column
FOREIGN KEY (column1, column2, ... column_n)
REFERENCES parent_table (column1, column2, ... column_n)