Different results when specifying DEFAULT values through ALTER TABLE - Mailing list pgsql-admin

From Thusitha Kodikara
Subject Different results when specifying DEFAULT values through ALTER TABLE
Date
Msg-id 200604190653.k3J6rHVo000891@rly18b.srv.mailcontrol.com
Whole thread Raw
Responses Re: Different results when specifying DEFAULT values through
List pgsql-admin
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
ofthe 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
existingrows. 

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.

pgsql-admin by date:

Previous
From: Tom Lane
Date:
Subject: Re: PGOPTS
Next
From: "koji osada"
Date:
Subject: Migration from oracle