<variablelist>
<varlistentry id="sql-altertable-desc-add-column">
- <term><literal>ADD COLUMN [ IF NOT EXISTS ]</literal></term>
+ <term><literal>ADD [ COLUMN ] [ IF NOT EXISTS ]</literal></term>
<listitem>
<para>
This form adds a new column to the table, using the same syntax as
</varlistentry>
<varlistentry id="sql-altertable-desc-drop-column">
- <term><literal>DROP COLUMN [ IF EXISTS ]</literal></term>
+ <term><literal>DROP [ COLUMN ] [ IF EXISTS ]</literal></term>
<listitem>
<para>
This form drops a column from a table. Indexes and
ALTER TABLE test_add_column
ADD COLUMN IF NOT EXISTS c5 SERIAL CHECK (c5 > 10);
NOTICE: column "c5" of relation "test_add_column" already exists, skipping
+ALTER TABLE test_add_column
+ ADD c6 integer; -- omit COLUMN
+ALTER TABLE test_add_column
+ ADD IF NOT EXISTS c6 integer;
+NOTICE: column "c6" of relation "test_add_column" already exists, skipping
+ALTER TABLE test_add_column
+ DROP c6; -- omit COLUMN
+ALTER TABLE test_add_column
+ DROP IF EXISTS c6;
+NOTICE: column "c6" of relation "test_add_column" does not exist, skipping
\d test_add_column*
Table "public.test_add_column"
Column | Type | Collation | Nullable | Default
\d test_add_column
ALTER TABLE test_add_column
ADD COLUMN IF NOT EXISTS c5 SERIAL CHECK (c5 > 10);
+ALTER TABLE test_add_column
+ ADD c6 integer; -- omit COLUMN
+ALTER TABLE test_add_column
+ ADD IF NOT EXISTS c6 integer;
+ALTER TABLE test_add_column
+ DROP c6; -- omit COLUMN
+ALTER TABLE test_add_column
+ DROP IF EXISTS c6;
\d test_add_column*
DROP TABLE test_add_column;
\d test_add_column*