diff options
author | Bruce Momjian <bruce@momjian.us> | 2001-05-09 13:27:15 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2001-05-09 13:27:15 +0000 |
commit | 1ef9338ab6f9ce47356c4eac2ea1a53f3131393b (patch) | |
tree | e6c9f99fe4ec6ada6b6d655754d9b44859366b5d /doc/src | |
parent | 6cda3ad8feb9b534fe9fb5866bbe5930596d0027 (diff) | |
download | postgresql-1ef9338ab6f9ce47356c4eac2ea1a53f3131393b.tar.gz postgresql-1ef9338ab6f9ce47356c4eac2ea1a53f3131393b.zip |
If it's true that the ALTER TABLE x ADD CONSTRAINT x CHECK (x) syntax is
supported in 7.1.1, here is a patch to that alter_table.sgml that documents
it.
Christopher Kings-Lynne
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/ref/alter_table.sgml | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml index 21fc8c2ebdb..5649890bf8f 100644 --- a/doc/src/sgml/ref/alter_table.sgml +++ b/doc/src/sgml/ref/alter_table.sgml @@ -1,5 +1,5 @@ <!-- -$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.23 2001/05/07 00:43:15 tgl Exp $ +$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.24 2001/05/09 13:27:15 momjian Exp $ Postgres documentation --> @@ -207,13 +207,10 @@ ALTER TABLE <replaceable class="PARAMETER">table</replaceable> </para> <para> - In the current implementation, only FOREIGN KEY constraints can + In the current implementation, only FOREIGN KEY and CHECK constraints can be added to a table. To create or remove a unique constraint, create a unique index (see <xref linkend="SQL-CREATEINDEX" - endterm="SQL-CREATEINDEX-title">). To add check constraints - you need to recreate and reload the table, using other - parameters to the <xref linkend="SQL-CREATETABLE" - endterm="SQL-CREATETABLE-title"> command. + endterm="SQL-CREATEINDEX-title">). </para> <para> @@ -257,6 +254,13 @@ ALTER TABLE distributors RENAME TO suppliers; </para> <para> + To add a check constraint to a table: + <programlisting> +ALTER TABLE distributors ADD CONSTRAINT zipchk CHECK (char_length(zipcode) = 5) + </programlisting> + </para> + + <para> To add a foreign key constraint to a table: <programlisting> ALTER TABLE distributors ADD CONSTRAINT distfk FOREIGN KEY (address) REFERENCES addresses(address) MATCH FULL |