2

Can anyone give me the command to remove the check constraint in workbench please? I used alter table details drop check details_chk_1; but it isnt working. It shows error in drop command. pls help

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343

3 Answers3

1

This is working in my workbench 8.0

alter table TABLE_NAME drop check CHECK_NAME;

The name can be found by running any command on the column. For eg: I ran

alter table movies rename column Release_Year to  Year ;

which gave me this error

18:03:57    alter table movies rename column Release_Year to  Year  Error Code: 3959. Check constraint 'movies_chk_1' uses column 'Release_Year', hence column cannot be dropped or renamed.    0.000 sec

From here you can use the name of the constraint and paste it to resolve the error. Here's the resolved response

18:04:14    alter table movies drop check movies_chk_1  0 row(s) affected Records: 0  Duplicates: 0  Warnings: 0    0.203 sec

18:10:17    alter table movies rename column Release_Year to  Year  0 row(s) affected Records: 0  Duplicates: 0  Warnings: 0    0.047 sec
blablabla
  • 39
  • 1
  • 7
0

Please try ALTER TABLE details ALTER CHECK details_chk_1 NOT ENFORCED;

Dave Stokes
  • 775
  • 4
  • 10
0

ALTER TABLE student DROP CONSTRAINT constraint_name;

you can set constraint name manually also ... but if you want to check constraint name which is auto set.. .then enter following query show create table table_name;