1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-20 15:22:23 +03:00

Allow ALTER TABLE ... ALTER CONSTRAINT ... RENAME

Joachim Wieland
This commit is contained in:
Bruce Momjian
2006-02-11 22:17:19 +00:00
parent 3fcb38f031
commit a02f6ce33b
12 changed files with 462 additions and 12 deletions

View File

@ -1,4 +1,4 @@
<!-- $PostgreSQL: pgsql/doc/src/sgml/ddl.sgml,v 1.52 2006/02/04 23:03:19 tgl Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/ddl.sgml,v 1.53 2006/02/11 22:17:18 momjian Exp $ -->
<chapter id="ddl">
<title>Data Definition</title>
@ -543,6 +543,10 @@ CREATE TABLE products (
price numeric
);
</programlisting>
Since <productname>PostgreSQL</productname> implements a UNIQUE constraint by
means of an index, the above command will also create an index with the same
name as the constraint. If you later on change the name of one of those, the
name of the corresponding object will be changed automatically as well.
</para>
<indexterm>

View File

@ -1,5 +1,5 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_index.sgml,v 1.6 2005/08/22 19:39:52 tgl Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_index.sgml,v 1.7 2006/02/11 22:17:18 momjian Exp $
PostgreSQL documentation
-->
@ -107,6 +107,15 @@ ALTER INDEX <replaceable class="PARAMETER">name</replaceable> SET TABLESPACE <re
of <command>ALTER TABLE</> that apply to indexes.
</para>
<para>
Indexes are also used internally by constraints, namely by UNIQUE and
PRIMARY KEY constraints. If you rename an index that is used internally by
a constraint of that type, this constraint will implicitly be renamed as
well. On the other hand, if you rename such a constraint, it will
implicitly rename its corresponding index such that both objects always
have the same name.
</para>
<para>
There was formerly an <command>ALTER INDEX OWNER</> variant, but
this is now ignored (with a warning). An index cannot have an owner

View File

@ -1,5 +1,5 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.82 2005/12/08 21:35:36 momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.83 2006/02/11 22:17:18 momjian Exp $
PostgreSQL documentation
-->
@ -24,6 +24,8 @@ ALTER TABLE [ ONLY ] <replaceable class="PARAMETER">name</replaceable> [ * ]
<replaceable class="PARAMETER">action</replaceable> [, ... ]
ALTER TABLE [ ONLY ] <replaceable class="PARAMETER">name</replaceable> [ * ]
RENAME [ COLUMN ] <replaceable class="PARAMETER">column</replaceable> TO <replaceable class="PARAMETER">new_column</replaceable>
ALTER TABLE [ ONLY ] <replaceable class="PARAMETER">name</replaceable> [ * ]
ALTER CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable> RENAME TO <replaceable class="PARAMETER">new_constraint_name</replaceable>
ALTER TABLE <replaceable class="PARAMETER">name</replaceable>
RENAME TO <replaceable class="PARAMETER">new_name</replaceable>
ALTER TABLE <replaceable class="PARAMETER">name</replaceable>
@ -169,6 +171,18 @@ where <replaceable class="PARAMETER">action</replaceable> is one of:
</listitem>
</varlistentry>
<varlistentry>
<term><literal>ALTER CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable> RENAME TO <replaceable class="PARAMETER">new_constraint_name</replaceable></literal></term>
<listitem>
<para>
This form renames a constraint that is defined on the table. Note that if
a constraint is using an index internally (<literal>UNIQUE</> or
<literal>PRIMARY KEY</> constraints), the corresponding index will be
renamed as well.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>ADD <replaceable class="PARAMETER">table_constraint</replaceable></literal></term>
<listitem>