SQL – Drop constraint without specifying its name

Drop a UNIQUE constraint in relational databases like Oracle without specifying its name by referencing the column or columns:

ALTER TABLE Employee DROP UNIQUE (name)

.

But if you want to drop a NOT NULL constraint  without specifying its name you have to use a workaround, if there is an index on the column:

ALTER TABLE Employee ADD (name_ varchar(32));
update Employee set name_ = name;
ALTER TABLE Employee DROP COLUMN name;
ALTER TABLE Employee ADD (name varchar(32));
update Employee set name = name_;
ALTER TABLE Employee DROP COLUMN name_;

.

To drop a NOT NULL constraint in Oracle you can MODIFY an unindexed column:

ALTER TABLE Employee MODIFY name NULL;

.

ps. Dieses Mal ein How-To-Posting aus meinem spannenden Leben als Software-Entwicklerin in Englisch, zum leichteren Wiederfinden in Suchmaschinen.