对于3,需要使用on delete cascade建立外键约束。实验: alter table emp_test add constraint fk_emp_dept_test foreign key(dept) references dept_test(deptno) on delete cascade; delete from dept_test where deptno = 1; 1 row deleted. SQL> select * from dept_test; DEPTNO DEPTNAME --- --- 2 ...
ON DELETE 子句可以有以下几种选项: CASCADE: 当主键表中的记录被删除时,外键表中的相应记录也会被自动删除。 CREATE TABLE Orders ( OrderID INT PRIMARY KEY, CustomerID INT, FOREIGN KEY (CustomerID) REFERENCES Customers(CustomerID) ON DELETE CASCADE ); 复制代码 SET NULL: 当主键表中的记录被删除时,...
`FileCreated` datetime DEFAULT '0000-00-00 00:00:00' COMMENT '创建时间', PRIMARY KEY (`FileID`), KEY `FK_tblfile_1` (`FileOwner`), CONSTRAINT `FK_tblfile_1` FOREIGN KEY (`FileOwner`) REFERENCES `tbluser` (`UserID`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCR...
命名空间: Microsoft.SqlServer.Management.UI.VSIntegration 程序集: SQLEditors.dll C# 复制 public bool OnDelete (bool bPhysicalDelete); 参数 bPhysicalDelete Boolean 返回 Boolean 适用于 产品版本 SQL Server .NET SDK 2016 本文内容 定义 适用于 ...
解析 A [解析] SQL语句中级联删除的语句是ON DELETE CASCADES,故本题选择 A。RESTRICTED表示受限删除,NULLIFIES表示置空值删除,DEFAULT表示默认情况。结果一 题目 SQL语言中,能正确实现级联删除的命令是( )。 A.ON DELETE CASCADESB.ON DELETE RESTRICTEDC.ON DELETE NULLIFIESD.ON DELETE DEFAULT 答案 A级联删除...
对于3,需要使用on delete cascade建立外键约束。实验: alter table emp_test add constraint fk_emp_dept_test foreign key(dept) references dept_test(deptno) on delete cascade; delete from dept_test where deptno = 1; 1 row deleted. SQL> select * from dept_test; DEPTNO DEPTNAME --- --- 2 ...
最后,我们可以使用以下SQL语句来添加ON DELETE SET NULL约束: 代码语言:sql 复制 ALTERTABLEbookADDCONSTRAINTfk_book_authorFOREIGNKEY(author_id)REFERENCESauthor(id)ONDELETESETNULL; 这样,当我们删除一个作者时,与其相关的书的author_id值将被设置为NULL。
对于3,需要使用on delete cascade建立外键约束。实验: alter table emp_test add constraint fk_emp_dept_test foreign key(dept) references dept_test(deptno) on delete cascade; delete from dept_test where deptno = 1; 1 row deleted. SQL> select * from dept_test; ...
This SQL Server tutorial explains how to use Foreign Keys with set null on delete in SQL Server with syntax and examples. If a record in the parent table is deleted, then the corresponding records in the child table will have the foreign key fields set t
SQL语言中,级联删除的短语是( )。 A.WHEN DELETE RESTRICT B.ON DELETE RESTRICT C.0N DELETE SET NULL D.0N DELETE CASCADE 正确答案:D SQL语言中,级联删除的短语是ON DELETE CASCADE。 以上是SQL语言中,级联删除的短语是( )。A.WHEN DELETE RESTRICTB.ON D的全部内容,更多关于SQL语言中,级联删除的短语...