CREATE UNIQUE INDEX IF NOT EXISTS in postgreSQL
ddl, indexing, postgresql, sql
Solution
You can check, if an index with a given name exists with this statement.
If your index name is `some_table_some_field_idx`
SELECT count(*) > 0
FROM pg_class c
WHERE c.relname = 'some_table_some_field_idx'
AND c.relkind = 'i';
Starting from Postgres 9.5 you can even use
CREATE INDEX IF NOT EXISTS
Problem
Plese I would like to do in PostgreSQL something like ``` CREATE UNIQUE INDEX IF NOT EXISTS ``` Any idea?