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.
First you need to know the exact name of the INDEX (Unique key in this case) to delete or update it. INDEX names are usually same as column names. In case of more than one INDEX applied on a column, MySQL automatically suffixes numbering to the column names to create unique INDEX names.
The syntax for dropping a unique constraint in Oracle is: ALTER TABLE table_name DROP CONSTRAINT constraint_name; table_name.
ALTER TABLE users DROP CONSTRAINT 'constraints_name'
if earlier constraints_name is not provided, it will have some default constraint_name, in pgAdmin 4 (pSql), try violating the constraint and you can see the constraint_name being violated in the error received, most probably same must be the case with other platforms or there are some articles available over web where constraint_name is extracted from certain tables where they are stored, not sure about this though. P.S : Can take reference from comments also
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With