Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9b77f61

Browse files
committed
ALTER TABLE SET/DROP NOT NULL, from Christopher Kings-Lynne.
1 parent838fe25 commit9b77f61

File tree

9 files changed

+506
-45
lines changed

9 files changed

+506
-45
lines changed

‎doc/src/sgml/ref/alter_table.sgml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
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 $
33
PostgreSQL documentation
44
-->
55

@@ -28,6 +28,8 @@ ALTER TABLE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> [ * ]
2828
ALTER TABLE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> [ * ]
2929
ALTER [ COLUMN ] <replaceable class="PARAMETER">column</replaceable> { SET DEFAULT <replaceable
3030
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
3133
ALTER TABLE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> [ * ]
3234
ALTER [ COLUMN ] <replaceable class="PARAMETER">column</replaceable> SET STATISTICS <replaceable class="PARAMETER">integer</replaceable>
3335
ALTER TABLE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> [ * ]
@@ -168,6 +170,9 @@ ALTER TABLE <replaceable class="PARAMETER">table</replaceable>
168170
allow you to set or remove the default for the column. Note that defaults
169171
only apply to subsequent <command>INSERT</command> commands; they do not
170172
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.
171176
The <literal>ALTER COLUMN SET STATISTICS</literal> form allows you to
172177
set the statistics-gathering target for subsequent
173178
<xref linkend="sql-analyze" endterm="sql-analyze-title"> operations.
@@ -279,6 +284,17 @@ ALTER TABLE distributors RENAME TO suppliers;
279284
</programlisting>
280285
</para>
281286

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+
282298
<para>
283299
To add a check constraint to a table:
284300
<programlisting>

‎doc/src/sgml/release.sgml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.128 2002/03/25 21:24:08 momjian Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.129 2002/04/01 04:35:37 tgl Exp $
33
-->
44

55
<appendix id="release">
@@ -24,6 +24,7 @@ CDATA means the content is "SGML-free", so you can write without
2424
worries about funny characters.
2525
-->
2626
<literallayout><![CDATA[
27+
ALTER TABLE ALTER COLUMN SET/DROP NOT NULL
2728
EXPLAIN output comes out as a query result, not a NOTICE message
2829
DOMAINs (types that are constrained versions of base types)
2930
Access privileges on functions

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp