gpt4 book ai didi

sql - ORA-00905 : missing keyword (copied from textbook)

转载 作者:行者123 更新时间:2023-12-04 20:20:10 25 4
gpt4 key购买 nike

已尝试上下查看代码,但无法使其正常工作。主要是尝试创建表功能。在尝试创建具有复合主键的表之前工作正常。绝对难倒。感谢您的帮助。

尝试删除键的名称,但随后被重定向到另一种错误:“无效数据类型”

Create Table Cust_Artist_EOI    (ArtistID   Number(38)  Not Null,
CustomerID Number(38) Not Null,
Constraint Cust_Artist_EOI_PK Primary Key(ArtistID, CustomerID),
Constraint Cust_Artist_EOI_ArtistFK Foreign Key(ArtistID)
References MyArtist(ArtistID)
On Update No Action
On Delete Cascade,
Constraint Cust_Artist_EOI_CustFK Foreign Key(CustomerID)
References MyCustomer(CustomerID)
On Update No Action
On Delete Cascade);

最佳答案

问题是更新。删除:

Create Table Cust_Artist_EOI  (
ArtistID Number(38) Not Null,
CustomerID Number(38) Not Null,
Constraint Cust_Artist_EOI_PK Primary Key(ArtistID, CustomerID),
Constraint Cust_Artist_EOI_ArtistFK Foreign Key(ArtistID)
References MyArtist(ArtistID) On Delete Cascade,
Constraint Cust_Artist_EOI_CustFK Foreign Key(CustomerID)
References MyCustomer(CustomerID) On Delete Cascade
);

Here是一个数据库<> fiddle 。

如果您查看 syntax diagram对于 Oracle 中的外键约束,您会看到既不支持 on update 也不支持 no action

我不确定为什么不支持 no action,因为这是默认行为(我认为能够表达默认行为是个好主意)。

不支持 on update 是一个更好的主意。它不鼓励更改主键。更改主键通常不是一个好主意。

关于sql - ORA-00905 : missing keyword (copied from textbook),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57638703/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com