@@ -1421,30 +1421,36 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
1421
1421
1422
1422
<para>
1423
1423
When a column is added with <literal>ADD COLUMN</literal> and a
1424
- non-volatile <literal>DEFAULT</literal> is specified, the default is
1424
+ non-volatile <literal>DEFAULT</literal> is specified, the default value is
1425
1425
evaluated at the time of the statement and the result stored in the
1426
- table's metadata. That value will be used for the column for all existing
1427
- rows. If no <literal>DEFAULT</literal> is specified, NULL is used. In
1428
- neither case is a rewrite of the table required.
1426
+ table's metadata, where it will be returned when any existing rows are
1427
+ accessed. The value will be only applied when the table is rewritten,
1428
+ making the <command>ALTER TABLE</command> very fast even on large tables.
1429
+ If no column constraints are specified, NULL is used as the
1430
+ <literal>DEFAULT</literal>. In neither case is a rewrite of the table
1431
+ required.
1429
1432
</para>
1430
1433
1431
1434
<para>
1432
- Adding a column with a volatile <literal>DEFAULT</literal> or
1433
- changing the type of an existing column will require the entire table and
1434
- its indexes to be rewritten. As an exception, when changing the type of an
1435
- existing column, if the <literal>USING</literal> clause does not change
1436
- the column contents and the old type is either binary coercible to the new
1437
- type or an unconstrained domain over the new type, a table rewrite is not
1438
- needed. However, indexes must always be rebuilt unless the system can
1439
- verify that the new index would be logically equivalent to the existing
1440
- one. For example, if the collation for a column has been changed, an index
1441
- rebuild is always required because the new sort order might be different.
1442
- However, in the absence of a collation change, a column can be changed
1443
- from <type>text</type> to <type>varchar</type> (or vice versa) without
1444
- rebuilding the indexes because these data types sort identically.
1445
- Table and/or index rebuilds may take a
1446
- significant amount of time for a large table; and will temporarily require
1447
- as much as double the disk space.
1435
+ Adding a column with a volatile <literal>DEFAULT</literal>
1436
+ (e.g., <function>clock_timestamp()</function>), a generated column
1437
+ (e.g., <literal>GENERATED BY DEFAULT AS IDENTITY</literal>), a domain
1438
+ data type with constraints will require the entire table and its
1439
+ indexes to be rewritten, as will changing the type of an existing
1440
+ column. As an exception, when changing the type of an existing column,
1441
+ if the <literal>USING</literal> clause does not change the column
1442
+ contents and the old type is either binary coercible to the new type
1443
+ or an unconstrained domain over the new type, a table rewrite is not
1444
+ needed. However, indexes must always be rebuilt unless the system
1445
+ can verify that the new index would be logically equivalent to the
1446
+ existing one. For example, if the collation for a column has been
1447
+ changed, an index rebuild is required because the new sort
1448
+ order might be different. However, in the absence of a collation
1449
+ change, a column can be changed from <type>text</type> to
1450
+ <type>varchar</type> (or vice versa) without rebuilding the indexes
1451
+ because these data types sort identically. Table and/or index
1452
+ rebuilds may take a significant amount of time for a large table,
1453
+ and will temporarily require as much as double the disk space.
1448
1454
</para>
1449
1455
1450
1456
<para>
0 commit comments