psql -d appdb -c "CREATE UNIQUE INDEX idx_users_email_unique ON users (email);"
Create a unique index
Creates an index that also enforces uniqueness: a second row with the same email is rejected, exactly like a UNIQUE constraint. Duplicates in existing data make the creation fail, so dedupe first.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.