summaryrefslogtreecommitdiff
path: root/doc/src/sgml/ref
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2016-02-07 16:02:44 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2016-02-07 16:02:44 -0500
commitc477e84fe2471cb675234fce75cd6bb4bc2cf481 (patch)
treeedae42dba0111b3dcfe6557ef49a7eb944f332c0 /doc/src/sgml/ref
parentcc2ca9319a5dbe89ea47d87944650e65e3bb4ce8 (diff)
Improve documentation about PRIMARY KEY constraints.
Get rid of the false implication that PRIMARY KEY is exactly equivalent to UNIQUE + NOT NULL. That was more-or-less true at one time in our implementation, but the standard doesn't say that, and we've grown various features (many of them required by spec) that treat a pkey differently from less-formal constraints. Per recent discussion on pgsql-general. I failed to resist the temptation to do some other wordsmithing in the same area.
Diffstat (limited to 'doc/src/sgml/ref')
-rw-r--r--doc/src/sgml/ref/create_table.sgml26
1 files changed, 13 insertions, 13 deletions
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index f0c94d591ef..cd234dbf4e3 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -506,25 +506,25 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXI
<term><literal>PRIMARY KEY ( <replaceable class="PARAMETER">column_name</replaceable> [, ... ] )</> (table constraint)</term>
<listitem>
<para>
- The primary key constraint specifies that a column or columns of a table
- can contain only unique (non-duplicate), nonnull values.
- Technically, <literal>PRIMARY KEY</literal> is merely a
- combination of <literal>UNIQUE</> and <literal>NOT NULL</>, but
- identifying a set of columns as primary key also provides
- metadata about the design of the schema, as a primary key
- implies that other tables
- can rely on this set of columns as a unique identifier for rows.
+ The <literal>PRIMARY KEY</> constraint specifies that a column or
+ columns of a table can contain only unique (non-duplicate), nonnull
+ values. Only one primary key can be specified for a table, whether as a
+ column constraint or a table constraint.
</para>
<para>
- Only one primary key can be specified for a table, whether as a
- column constraint or a table constraint.
+ The primary key constraint should name a set of columns that is
+ different from the set of columns named by any unique
+ constraint defined for the same table. (Otherwise, the unique
+ constraint is redundant and will be discarded.)
</para>
<para>
- The primary key constraint should name a set of columns that is
- different from other sets of columns named by any unique
- constraint defined for the same table.
+ <literal>PRIMARY KEY</literal> enforces the same data constraints as
+ a combination of <literal>UNIQUE</> and <literal>NOT NULL</>, but
+ identifying a set of columns as the primary key also provides metadata
+ about the design of the schema, since a primary key implies that other
+ tables can rely on this set of columns as a unique identifier for rows.
</para>
</listitem>
</varlistentry>