At what level do Postgres index names need to be unique?

前端 未结 2 1412
不知归路
不知归路 2021-01-03 20:20

In Microsoft SQL Server and MySQL, index names need to unique within the table, but not within the database. This doesn\'t seem to be the case for PostgreSQL.

Here\'

2条回答
  •  情话喂你
    2021-01-03 20:40

    • Names are unique within the schema. A schema is basically a namespace for {tables,constraints}, (and indexes, functions,etc).
    • cross-schema-constraints are allowed
    • Indexes share their namespace ( :=schema) with tables. (for Postgres: an index is a table).
    • (IIRC) the SQL standard does not define indexes; use constraints whenever you can (The GIST index in the question is probably an exception)
    • Ergo You'll need to invent another name.
    • or omit it: the system can invent a name if you dont supply one.
    • The downside of this: you can create multipe indices with the same definition (their names will be suffixed with _1, _2, IIRC)

提交回复
热议问题