I have a table 'users' with 'login' column defined as:
[login] VARCHAR(50) UNIQUE NOT NULL
Now I want to remove this unique constraint/index using SQL script. I found its name UQ_users_7D78A4E7 in my local database but I suppose it has a different name on another database.
What is the best way to drop this unique constraint? Or at least any...
Thanks.
If you know the name of your constraint then you can directly use the command like
alter table users drop constraint constraint_name;
If you don't know the constraint name, you can get the constraint by using this command
select constraint_name,constraint_type from user_constraints where table_name = 'YOUR TABLE NAME';
I had the same problem. I'm using DB2. What I have done is a bit not too professional solution, but it works in every DBMS:
The syntax of the ALTER commands may be different in other DBMS
SKINDER, your code does not use column name. Correct script is:
Use this SQL command to drop a unique constraint:
To drop a UNIQUE constraint, you don’t need the name of the constraint, just the list of columns that are included in the constraint.
The syntax would be: