From d0283387d358e5e0a64a439b7fe906399b59fdd9 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Wed, 31 Jan 2024 11:53:56 +0100 Subject: [PATCH] doc: Document more that relations share a namespace This was already documented in the CREATE INDEX reference, but not in the introductory "Data Definition" chapter. Also, document that the index that implements a constraint has the same name as the constraint. Author: Laurenz Albe Reviewed-by: jian he Reviewed-by: David G. Johnston Discussion: https://www.postgresql.org/message-id/flat/CACJufxFG682tYcP9aH_F-jrqq5End8MHZR77zcp1%3DDUrEsSu1Q%40mail.gmail.com --- doc/src/sgml/ddl.sgml | 6 +++++- doc/src/sgml/ref/create_table.sgml | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml index 0a0ff42e88..9d7e2c756b 100644 --- a/doc/src/sgml/ddl.sgml +++ b/doc/src/sgml/ddl.sgml @@ -3003,7 +3003,11 @@ SELECT * FROM information WHERE group_id = 2 FOR UPDATE; A database contains one or more named schemas, which in turn contain tables. Schemas also contain other kinds of named - objects, including data types, functions, and operators. The same + objects, including data types, functions, and operators. Within one + schema, two objects of the same type cannot have the same name. + Furthermore, tables, sequences, indexes, views, materialized views, and + foreign tables share the same namespace, so that, for example, an index and + a table must have different names if they are in the same schema. The same object name can be used in different schemas without conflict; for example, both schema1 and myschema can contain tables named mytable. Unlike databases, diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml index d563f02b00..4cbaaccaf7 100644 --- a/doc/src/sgml/ref/create_table.sgml +++ b/doc/src/sgml/ref/create_table.sgml @@ -1027,7 +1027,8 @@ WITH ( MODULUS numeric_literal, REM Adding a unique constraint will automatically create a unique B-tree index on the column or group of columns used in the constraint. But if the constraint includes a WITHOUT OVERLAPS clause, it - will use a GiST index. + will use a GiST index. The created index has the same name as the unique + constraint. @@ -1082,6 +1083,7 @@ WITH ( MODULUS numeric_literal, REM PRIMARY KEY constraint will automatically create a unique B-tree index, or GiST if WITHOUT OVERLAPS was specified, on the column or group of columns used in the constraint. + That index has the same name as the primary key constraint. @@ -1118,8 +1120,8 @@ WITH ( MODULUS numeric_literal, REM Exclusion constraints are implemented using - an index, so each specified operator must be associated with an - appropriate operator class + an index that has the same name as the constraint, so each specified + operator must be associated with an appropriate operator class (see ) for the index access method index_method. The operators are required to be commutative.