Be more clear what names can be used for tables with "CREATE TABLE"?

Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>

From: "Daniel Westermann (DWE)" <daniel.westermann@dbi-services.com>
To: "pgsql-docs@lists.postgresql.org" <pgsql-docs@lists.postgresql.org>
Date: 2021-10-30T11:08:15Z
Lists: pgsql-docs
HI all,

in the documentation for CREATE TABLE we have this sentence:

"The name of the table must be distinct from the name of any other table, sequence, index, view, or foreign table in the same schema."

At least materialized views are missing:

postgres=# create materialized view t as select 1;
SELECT 1
postgres=# create table t ( a int );
ERROR:  relation "t" already exists
postgres=# drop materialized view t;
DROP MATERIALIZED VIEW

Domains are also missing:

postgres=# create domain t as int;
CREATE DOMAIN
postgres=# create table t ( a int );
ERROR:  type "t" already exists
HINT:  A relation has an associated type of the same name, so you must use a name that doesn't conflict with any existing type.
postgres=# drop domain t;
DROP DOMAIN

... but that maybe is covered by the next paragraph?

"CREATE TABLE also automatically creates a data type that represents the composite type corresponding to one row of the table. Therefore, tables cannot have the same name as any existing data type in the same schema."

Regards
Daniel


Commits

  1. Doc: be more precise about conflicts between relation names.