Skip site navigation (1) Skip section navigation (2)

Re: set default: question

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Marco Bomben <marco(dot)bomben(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: set default: question
Date: 2010-04-22 22:16:55
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
Marco Bomben <marco(dot)bomben(at)gmail(dot)com> writes:
> I've a problem in understanding the "SET DEFAULT" command.
> fssr2db=# ALTER TABLE fssr2calibs ALTER COLUMN  intvbn SET DEFAULT 139;
> ...
> So I do see the effects of SET DEFAULT on the table as a whole (through \d
> <table name>)
> but not on each row (I set the value for some of them and for some not
> before using SET DEFAULT).

SET DEFAULT only establishes a default to use in future INSERT
operations; it doesn't affect any existing rows.  Perhaps you want
to do something like

	UPDATE fssr2calibs SET intvbn = 139 WHERE intvbn IS NULL

in addition to setting the default?

			regards, tom lane

In response to

pgsql-novice by date

Next:From: Tim BunceDate: 2010-04-23 10:31:12
Subject: Re: PLPerl not installed correctly?
Previous:From: Daniel HutchisonDate: 2010-04-22 16:00:24
Subject: Re: PLPerl not installed correctly?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group