From: Thusitha Kodikara <tkodikara@openworld.org>
To: pgsql-admin@postgresql.org
Subject: Different results when specifying DEFAULT values through ALTER TABLE
Date: Wed, 19 Apr 2006 12:28:27 +0530
Message-ID: <200604190653.k3J6rHVo000891@rly18b.srv.mailcontrol.com> (raw)
Hi,
I observed the following on PostgreSQL 8.1.3 (on Windows 2000).
(1) alter table invoice add column active boolean default true;
This will add a new column "active" with a default clause as "true" and also sets the value "true" to all existing rows of the table.
BUT
(2) ALTER TABLE invoice ADD COLUMN active boolean;
ALTER TABLE invoice ALTER COLUMN active SET DEFAULT true;
Will result in only adding the column "active" with default clause as "true". It will NOT set the value "true" for existing rows.
Is there a particular reason for this difference in behaviour? (Or am I missing something in the syntax?)
Thanks and regards,
-Thusitha Kodikara
--
CONFIDENTIALITY NOTICE The information contained in this message is
confidential, intended only for the use of the individual or the entity
named as recipient. If the reader of this message is not that recipient,
you are notified that any dissemination, distribution or copy of this
message is strictly prohibited. If you have received this message in
error, please immediately notify us by telephone on the number above.
Your co-operation is appreciated.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: tkodikara@openworld.org
Subject: Re: Different results when specifying DEFAULT values through ALTER TABLE
In-Reply-To: <200604190653.k3J6rHVo000891@rly18b.srv.mailcontrol.com>
References: <200604190653.k3J6rHVo000891@rly18b.srv.mailcontrol.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox