|
1 | 1 | <!--
|
2 |
| -$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.23 2001/05/07 00:43:15tgl Exp $ |
| 2 | +$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.24 2001/05/09 13:27:15momjian Exp $ |
3 | 3 | Postgres documentation
|
4 | 4 | -->
|
5 | 5 |
|
@@ -207,13 +207,10 @@ ALTER TABLE <replaceable class="PARAMETER">table</replaceable>
|
207 | 207 | </para>
|
208 | 208 |
|
209 | 209 | <para>
|
210 |
| - In the current implementation, only FOREIGN KEY constraints can |
| 210 | + In the current implementation, only FOREIGN KEYand CHECKconstraints can |
211 | 211 | be added to a table. To create or remove a unique constraint, create
|
212 | 212 | a unique index (see <xref linkend="SQL-CREATEINDEX"
|
213 |
| - endterm="SQL-CREATEINDEX-title">). To add check constraints |
214 |
| - you need to recreate and reload the table, using other |
215 |
| - parameters to the <xref linkend="SQL-CREATETABLE" |
216 |
| - endterm="SQL-CREATETABLE-title"> command. |
| 213 | + endterm="SQL-CREATEINDEX-title">). |
217 | 214 | </para>
|
218 | 215 |
|
219 | 216 | <para>
|
@@ -256,6 +253,13 @@ ALTER TABLE distributors RENAME TO suppliers;
|
256 | 253 | </programlisting>
|
257 | 254 | </para>
|
258 | 255 |
|
| 256 | + <para> |
| 257 | + To add a check constraint to a table: |
| 258 | + <programlisting> |
| 259 | +ALTER TABLE distributors ADD CONSTRAINT zipchk CHECK (char_length(zipcode) = 5) |
| 260 | + </programlisting> |
| 261 | + </para> |
| 262 | + |
259 | 263 | <para>
|
260 | 264 | To add a foreign key constraint to a table:
|
261 | 265 | <programlisting>
|
|