Re: Behaviour adding a column with and without a default (prior to PG11)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joe Horsnell <Joe(at)bambooloans(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Behaviour adding a column with and without a default (prior to PG11)
Date: 2019-09-30 21:19:10
Message-ID: 27688.1569878350@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Joe Horsnell <Joe(at)bambooloans(dot)com> writes:
> The documentation (https://www.postgresql.org/docs/10/ddl-alter.html) clearly states that adding a column with a default requires updating all the rows in the table, to store the new column value (this is prior to PG11, obviously).

> Obviously the desired effect of adding the column default without rewriting all the rows in the table can be achieved by adding the nullable column first with no default, then changing the default, but out of curiosity; was there a specific technical reason for the behaviour described above, or was it a conscious design choice?

We read the SQL spec as requiring this behavior.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joe Horsnell 2019-09-30 21:23:46 Re: Behaviour adding a column with and without a default (prior to PG11)
Previous Message Gerrit Fouche 2019-09-30 20:37:45 Re: pg_upgrade (Checking for reg* data types)