How to get the name of a unique constraint in postgresql?

That is something like (for single column constaint):

tableName_columnName_key

To get constaint name write (in psql):

\d tableName

or use pg_constraint system catalog:

SELECT conname
FROM pg_constraint
WHERE conrelid =
    (SELECT oid 
    FROM pg_class
    WHERE relname LIKE 'tableName');

Also you can get it from pgAdmin in objects tree.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)