From: Jade Lovelace <ja...@mercury.com>

I have intentionally been careful to not guarantee that the
automatically generated name *is* what's documented, but instead give
the general idea.

Knowing the format is useful for people writing migrations/ORM tools
which need to name their unique indices and may wish to use the
automatic naming system.

Signed-off-by: Jade Lovelace <ja...@mercury.com>
---
 doc/src/sgml/ref/create_index.sgml |  9 +++++++--
 doc/src/sgml/ref/create_table.sgml | 30 ++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/doc/src/sgml/ref/create_index.sgml 
b/doc/src/sgml/ref/create_index.sgml
index a5bac9f..7354267 100644
--- a/doc/src/sgml/ref/create_index.sgml
+++ b/doc/src/sgml/ref/create_index.sgml
@@ -206,9 +206,14 @@ CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] [ [ IF NOT EXISTS 
] <replaceable class=
         table.  The name of the index must be distinct from the name of any
         other relation (table, sequence, index, view, materialized view, or
         foreign table) in that schema.
+       </para>
+       <para>
         If the name is omitted, <productname>PostgreSQL</productname> chooses a
-        suitable name based on the parent table's name and the indexed column
-        name(s).
+        suitable name based on the parent table's name and the indexed
+        column name(s). Generally, teh generated name will be something of the
+        shape <literal>tablename_columnname_idx</literal>, but this may vary in
+        the event of long table names, where it is truncated, or if the index
+        already exists, where a number is appended.
        </para>
       </listitem>
      </varlistentry>
diff --git a/doc/src/sgml/ref/create_table.sgml 
b/doc/src/sgml/ref/create_table.sgml
index 6bbf15e..bdabd86 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -796,6 +796,36 @@ WITH ( MODULUS <replaceable 
class="parameter">numeric_literal</replaceable>, REM
       (Double-quotes are needed to specify constraint names that contain 
spaces.)
       If a constraint name is not specified, the system generates a name.
      </para>
+     <para>
+      Generally, the generated name will be something of the shape
+      <literal>tablename_columnname_constrainttype</literal>, but this may 
vary in the
+      event of long table names, where it is truncated, or if the index
+      already exists, where a number is appended.
+      <literal>constrainttype</literal> is one of the following:
+
+      <itemizedlist>
+       <listitem>
+        <para><literal>pkey</literal> in the case of primary keys</para>
+       </listitem>
+       <listitem>
+        <para>
+         <literal>excl</literal> in the case of
+         <link linkend="sql-createtable-exclude">
+          <literal>EXCLUDE</literal>
+         </link> constraints.
+        </para>
+       </listitem>
+       <listitem>
+        <para>
+         <literal>key</literal> in the case of
+         <link linkend="sql-createtrigger"><firstterm>constraint 
triggers</firstterm></link>.
+        </para>
+       </listitem>
+       <listitem>
+        <para><literal>idx</literal> in other cases.</para>
+       </listitem>
+      </itemizedlist>
+     </para>
     </listitem>
    </varlistentry>
 
-- 
2.37.1



Reply via email to