Re: Lazy constraints / defaults
| От | Tom Lane |
|---|---|
| Тема | Re: Lazy constraints / defaults |
| Дата | |
| Msg-id | 10863.1205087115@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Lazy constraints / defaults ("Michał Zaborowski" <michal.zaborowski@gmail.com>) |
| Ответы |
Re: Lazy constraints / defaults
|
| Список | pgsql-hackers |
"Michał Zaborowski" <michal.zaborowski@gmail.com> writes:
> I would like to be able to add CONSTRAINT and/or DEFAULT with out
> affecting old rows.
You mean without actually checking that the old rows satisfy the
constraint? There's approximately zero chance that that proposal
will be accepted.
> Yes, it sounds strange, but... Let's say I have
> big table, I want to add new column, with DEFAULT and NOT NULL.
> Normally it means long exclusive lock. So - right now I'm adding plain
> new column, then DEFAULT, then UPDATE on all rows in chunks, then NOT
> NULL... Can it be little simpler?
Just do it all in one ALTER command.
alter table tab add column col integer not null default 42 check (col > 0);
regards, tom lane
В списке pgsql-hackers по дате отправления: