When creating a table in PostgreSQL, default constraint names will assigned if not provided:
CREATE TABLE example (
a integer,
b integer,
UNIQUE
The manual is pretty clear about this ("tableconstraint: This form adds a new constraint to a table using the same syntax as CREATE TABLE.")
So you can simply run:
ALTER TABLE example ADD UNIQUE (a, b);
The standard names for indexes in PostgreSQL are:
{tablename}_{columnname(s)}_{suffix}
where the suffix is one of the following:
pkey
for a Primary Key constraintkey
for a Unique constraintexcl
for an Exclusion constraintidx
for any other kind of indexfkey
for a Foreign keycheck
for a Check constraintStandard suffix for sequences is
seq
for all sequencesProof of your UNIQUE-constraint:
NOTICE: CREATE TABLE / UNIQUE will create implicit index "example_a_b_key" for table "example"