I figured it out from the PostgreSQL docs, the exact syntax is:
ALTER TABLE the_table ADD CONSTRAINT constraint_name UNIQUE (thecolumn);
Thanks Fred.
More Related Contents:
- How to delete duplicate entries?
- ERROR: there is no unique constraint matching given keys for referenced table “bar”
- Select rows which are not present in other table
- Optimize GROUP BY query to retrieve latest row per user
- How to implement a many-to-many relationship in PostgreSQL?
- Aggregate columns with additional (distinct) filters
- Check if value exists in Postgres array
- Insert data in 3 tables at a time using Postgres
- How to use ANY instead of IN in a WHERE clause?
- Is there a shortcut for SELECT * FROM?
- sql statement error: “column .. does not exist”
- Concatenate multiple result rows of one column into one, group by another column [duplicate]
- sql ORDER BY multiple values in specific order?
- Constraint defined DEFERRABLE INITIALLY IMMEDIATE is still DEFERRED?
- Simulate CREATE DATABASE IF NOT EXISTS for PostgreSQL?
- Sorting null values after all others, except special
- Reference alias in WHERE clause
- NOT NULL constraint over a set of columns
- ERROR: functions in index expression must be marked IMMUTABLE in Postgres
- Why postgres returns unordered data in select query, after updation of row?
- postgresql – sql – count of `true` values
- What is the difference between a LATERAL JOIN and a subquery in PostgreSQL?
- Creating temporary tables in SQL
- PostgreSQL where all in array
- PostgreSQL – fetch the rows which have the Max value for a column in each GROUP BY group
- Conditional SQL count
- How to get a list column names and datatypes of a table in PostgreSQL?
- Postgresql query between date ranges
- Why isn’t row level security enabled for Postgres views?
- Is there a postgres CLOSEST operator?