|
1 | 1 | <!--
|
2 |
| -$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.40 2002/03/06 20:42:38 momjian Exp $ |
| 2 | +$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.41 2002/04/01 04:35:37 tgl Exp $ |
3 | 3 | PostgreSQL documentation
|
4 | 4 | -->
|
5 | 5 |
|
@@ -28,6 +28,8 @@ ALTER TABLE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> [ * ]
|
28 | 28 | ALTER TABLE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> [ * ]
|
29 | 29 | ALTER [ COLUMN ] <replaceable class="PARAMETER">column</replaceable> { SET DEFAULT <replaceable
|
30 | 30 | class="PARAMETER">value</replaceable> | DROP DEFAULT }
|
| 31 | +ALTER TABLE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> [ * ] |
| 32 | + ALTER [ COLUMN ] <replaceable class="PARAMETER">column</replaceable> { SET | DROP } NOT NULL |
31 | 33 | ALTER TABLE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> [ * ]
|
32 | 34 | ALTER [ COLUMN ] <replaceable class="PARAMETER">column</replaceable> SET STATISTICS <replaceable class="PARAMETER">integer</replaceable>
|
33 | 35 | ALTER TABLE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> [ * ]
|
@@ -168,6 +170,9 @@ ALTER TABLE <replaceable class="PARAMETER">table</replaceable>
|
168 | 170 | allow you to set or remove the default for the column. Note that defaults
|
169 | 171 | only apply to subsequent <command>INSERT</command> commands; they do not
|
170 | 172 | cause rows already in the table to change.
|
| 173 | + The <literal>ALTER COLUMN SET/DROP NOT NULL</literal> forms allow you to |
| 174 | + change whether a column is marked to allow NULL values or to reject NULL |
| 175 | + values. |
171 | 176 | The <literal>ALTER COLUMN SET STATISTICS</literal> form allows you to
|
172 | 177 | set the statistics-gathering target for subsequent
|
173 | 178 | <xref linkend="sql-analyze" endterm="sql-analyze-title"> operations.
|
@@ -279,6 +284,17 @@ ALTER TABLE distributors RENAME TO suppliers;
|
279 | 284 | </programlisting>
|
280 | 285 | </para>
|
281 | 286 |
|
| 287 | + <para> |
| 288 | + To add a NOT NULL constraint to a column: |
| 289 | + <programlisting> |
| 290 | +ALTER TABLE distributors ALTER COLUMN street SET NOT NULL; |
| 291 | + </programlisting> |
| 292 | + To remove a NOT NULL constraint from a column: |
| 293 | + <programlisting> |
| 294 | +ALTER TABLE distributors ALTER COLUMN street DROP NOT NULL; |
| 295 | + </programlisting> |
| 296 | + </para> |
| 297 | + |
282 | 298 | <para>
|
283 | 299 | To add a check constraint to a table:
|
284 | 300 | <programlisting>
|
|
0 commit comments