Re: Table Rewrite During ALTER TABLE ... ADD COLUMN ... DEFAULT NULL - Mailing list pgsql-general

From Tom Lane
Subject Re: Table Rewrite During ALTER TABLE ... ADD COLUMN ... DEFAULT NULL
Date
Msg-id 3036.1396497272@sss.pgh.pa.us
Whole thread Raw
In response to Table Rewrite During ALTER TABLE ... ADD COLUMN ... DEFAULT NULL  (Amit Langote <amitlangote09@gmail.com>)
Responses Re: Table Rewrite During ALTER TABLE ... ADD COLUMN ... DEFAULT NULL  (Amit Langote <amitlangote09@gmail.com>)
List pgsql-general
Amit Langote <amitlangote09@gmail.com> writes:
> When I do the following:

> ALTER TABLE table ADD COLUMN numeric(x) DEFAULT NULL;

> The table is rewritten whereas notes section on the manual page for
> ALTER TABLE says otherwise (which holds true for most of the cases
> though).

Try it without the explicit DEFAULT clause.

Some experimentation suggests that we are smart about "DEFAULT NULL"
unless the column type requires a length-coercion cast, in which
case the default expression involves a function call, and that doesn't
get elided.

            regards, tom lane


pgsql-general by date:

Previous
From: Amit Langote
Date:
Subject: Table Rewrite During ALTER TABLE ... ADD COLUMN ... DEFAULT NULL
Next
From: Amit Langote
Date:
Subject: Re: Table Rewrite During ALTER TABLE ... ADD COLUMN ... DEFAULT NULL