postgres
test=# CREATE TABLE test (a text, b text); CREATE TABLE test=# ALTER TABLE test ADD CONSTRAINT a_b_key UNIQUE (a, b); NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "a_b_key" for table "test" ALTER TABLE test=# Create UNIQUE INDEX a_b_idx ON test (a, b); CREATE INDEX
test=# \d test Table "public.test" Column | Type | Modifiers --------+------+----------- a | text | b | text | Indexes: "a_b_idx" UNIQUE, btree (a, b) "a_b_key" UNIQUE, btree (a, b) test=# SELECT * FROM information_schema.table_constraints WHERE table_name='test'; constraint_catalog | constraint_schema | constraint_name | table_catalog | table_schema | table_name | constraint_type | is_deferrable | initially_deferred --------------------+-------------------+-----------------+---------------+--------------+------------+-----------------+---------------+-------------------- dpj_test | public | a_b_key | dpj_test | public | test | UNIQUE | NO | NO (1 row)
PostgreSQL: Re: How to checking the existance of constraints for a table?