drop foreign key
snippet in sql

how to remove foreign key constraint in sql

user5029

USE AdventureWorks2012;  
GO  
ALTER TABLE dbo.DocExe   
DROP CONSTRAINT FK_Column_B;   
GO  

mysql add foreign key

user9358

-- On Create
CREATE TABLE tableName (
    ID INT,
    SomeEntityID INT,
    PRIMARY KEY (ID),
    FOREIGN KEY (SomeEntityID)
        REFERENCES SomeEntityTable(ID)
        ON DELETE CASCADE
);

-- On Alter, if the column already exists but has no FK
ALTER TABLE
  tableName
ADD
  FOREIGN KEY (SomeEntityID) REFERENCES SomeEntityTable(ID) ON DELETE CASCADE;

delete foreign key sql

user9355


ALTER TABLE Orders

DROP CONSTRAINT FK_PersonOrder; 

drop foreign key

user7941

ALTER TABLE table_name
DROP CONSTRAINT fk_name;

alter table foriegn key sql

user6295


ALTER TABLE Orders

ADD FOREIGN KEY (PersonID)
REFERENCES Persons(PersonID);