Home > OS >  How do I remove a DEFAULT constraint?
How do I remove a DEFAULT constraint?

Time:11-14

This is what I tried. I simply want to remove the constraint I just did there

ALTER TABLE product
ADD DEFAULT NULL FOR sale_id

ALTER TABLE product
ALTER COLUMN sale_id DROP DEFAULT

CodePudding user response:

ALTER TABLE TABLE_NAME
DROP CONSTRAINT <constraint_name>

Eg:

ALTER TABLE students
ALTER COLUMN ph
DROP NOT NULL;

CodePudding user response:

While looking into some solutions, I found the below mentioned link to be useful as per your issue of removing default constraint in SQL.

Link : https://stackoverflow.com/a/32650424/14181700

Please let me know if this was helpful.

  • Related