Re: effective SELECT from child tables

Поиск
Список
Период
Сортировка
Искать
От
Greg Stark
Тема
Re: effective SELECT from child tables
Дата
Msg-id
877jct9azb.fsf@stark.xeocode.com
Ответ на
Список
Дерево обсуждения
effective SELECT from child tables "Ilia Kantor" <ilia@obnovlenie.ru>
Re: effective SELECT from child tables Josh Berkus <josh@agliodbs.com>
Re: effective SELECT from child tables "Ilia Kantor" <ilia@obnovlenie.ru>
Re: effective SELECT from child tables Josh Berkus <josh@agliodbs.com>
Re: effective SELECT from child tables mark@mark.mielke.cc
Re: effective SELECT from child tables Tom Lane <tgl@sss.pgh.pa.us>
Re: effective SELECT from child tables "Ilia Kantor" <ilia@obnovlenie.ru>
Re: effective SELECT from child tables Simon Riggs <simon@2ndquadrant.com>
Re: effective SELECT from child tables "Jim C. Nasby" <jnasby@pervasive.com>
Re: effective SELECT from child tables Simon Riggs <simon@2ndquadrant.com>
Re: effective SELECT from child tables "Jim C. Nasby" <jnasby@pervasive.com>
Re: effective SELECT from child tables Martijn van Oosterhout <kleptog@svana.org>
Re: effective SELECT from child tables "Jim C. Nasby" <jnasby@pervasive.com>
Re: effective SELECT from child tables Andrew Dunstan <andrew@dunslane.net>
Re: effective SELECT from child tables "Ilia Kantor" <ilia@obnovlenie.ru>
Re: effective SELECT from child tables Martijn van Oosterhout <kleptog@svana.org>
Re: effective SELECT from child tables Simon Riggs <simon@2ndquadrant.com>
Re: effective SELECT from child tables mark@mark.mielke.cc
Re: effective SELECT from child tables Martijn van Oosterhout <kleptog@svana.org>
Re: effective SELECT from child tables "Jim C. Nasby" <jnasby@pervasive.com>
Re: effective SELECT from child tables Simon Riggs <simon@2ndquadrant.com>
Re: effective SELECT from child tables Hannu Krosing <hannu@skype.net>
Re: effective SELECT from child tables Greg Stark <gsstark@mit.edu>
Re: effective SELECT from child tables Hannu Krosing <hannu@skype.net>
Re: effective SELECT from child tables Martijn van Oosterhout <kleptog@svana.org>
Re: effective SELECT from child tables Hannu Krosing <hannu@skype.net>
Re: effective SELECT from child tables Martijn van Oosterhout <kleptog@svana.org>
Re: effective SELECT from child tables Greg Stark <gsstark@mit.edu>
Re: effective SELECT from child tables Hannu Krosing <hannu@skype.net>
Re: effective SELECT from child tables Greg Stark <gsstark@mit.edu>
Re: effective SELECT from child tables Tom Lane <tgl@sss.pgh.pa.us>
Re: effective SELECT from child tables Hannu Krosing <hannu@skype.net>
Re: effective SELECT from child tables Greg Stark <gsstark@mit.edu>
Re: effective SELECT from child tables Rod Taylor <pg@rbt.ca>
Re: effective SELECT from child tables Rod Taylor <pg@rbt.ca>
Re: effective SELECT from child tables Greg Stark <gsstark@mit.edu>
Re: effective SELECT from child tables "Jim C. Nasby" <jnasby@pervasive.com>
Re: effective SELECT from child tables Greg Stark <gsstark@mit.edu>
Re: effective SELECT from child tables Greg Stark <gsstark@mit.edu>
Re: effective SELECT from child tables "Jim C. Nasby" <jnasby@pervasive.com>
Re: effective SELECT from child tables Martijn van Oosterhout <kleptog@svana.org>
Re: effective SELECT from child tables "Jim C. Nasby" <jnasby@pervasive.com>
Re: effective SELECT from child tables mark@mark.mielke.cc
Re: effective SELECT from child tables mark@mark.mielke.cc
Re: effective SELECT from child tables "Jim C. Nasby" <jnasby@pervasive.com>
Rod Taylor  writes:

> > Hm. So you're saying there are only ever exactly two types of defaults. The
> > "initial" default that applies to all tuples that were created before the
> > column was added. And the "current" default that only ever applies to newly
> > created tuples.
> > 
> > That does seem to cleanly close this hole.
> 
> I don't think so.
> 
> ALTER TABLE tab ADD foo integer DEFAULT 1;
> INSERT INTO tab DEFAULT VALUES;

This inserts a physical "1" in the record (the "current" default").

> ALTER TABLE tab ALTER foo SET DEFAULT 2
> INSERT INTO tab DEFAULT VALUES;

This inserts a physical "2" in the record.

> ALTER TABLE tab ALTER foo SET DEFAULT 3
> INSERT INTO tab DEFAULT VALUES;

This inserts a physical "3" in the record.

> SELECT foo FROM tab;

This checks for any old records that predate the column and use the "initial"
default of 1 for those records. The three records above all postdate the
column addition so they have values present, namely 1, 2, and 3.

-- 
greg


В списке pgsql-hackers по дате отправления
От: Rod Taylor
Дата:
От: Tom Lane
Дата:
FAQ