It may cause loops or multiple cascade paths. Specify on delete no action or on update no action, or modify other foreign key constraints .,

Source: Internet
Author: User

It may cause loops or multiple cascade paths. Specify on delete no action or on update no action, or modify other foreign key constraints .,

Error message: it may cause loops or multiple cascade paths. Specify on delete no action or on update no action, or modify other foreign key constraints.

Cause: cascading deletion and cascading update are not allowed for a self-join table (the same table is connected to itself.

I. SQL statements

Create table DataClass (
    CID nvarchar(6) not null,
    ParentID nvarchar(6) null,
    CNAME nvarchar(50) not null,
    ENAME nvarchar(50) not null,
    DISCRIB nvarchar(200) null,
    DATATYPE smallint null,
    Constraint PK_DATACLASS primary key (CID)
)
Go

Create unique index IX_DataClass on DataClass (
ENAME ASC
)
Go

Alter table DataClass
Drop constraint FK_DataType_self
-- Error: May cause loops or multiple cascade paths. Please specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
--alter table DataClass
-- add constraint FK_DataType_self foreign key (ParentID)
-- references DataClass (CID)
-- on update cascade
--go

-- changed to:
Alter table DataClass
    Add constraint FK_DataType_self foreign key (ParentID)
       References DataClass (CID)
          On update NO ACTION
Go

 

Ii. Discovery

On update no action can be omitted because this mechanism is used by default.


The content is as follows:

USE [Ecology]
GO

Alter table [dbo]. [DataClass] with check add constraint [FK_DataType_self] foreign key ([ParentID])
REFERENCES [dbo]. [DataClass] ([CID])
GO

Alter table [dbo]. [DataClass] check constraint [FK_DataType_self]
GO

 

Sqlserver automatically omitting on update NO ACTION

 SQL constraints can be modified:
alter table DataClass
   add constraint FK_DataType_self foreign key (ParentID)
      references DataClass (CID)
go

You do not need to set this parameter in PowderDesigner.


 


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.