Обсуждение: RE: Happy column adding (was RE: [HACKERS] Happy column dropping)

Поиск
Список
Период
Сортировка

RE: Happy column adding (was RE: [HACKERS] Happy column dropping)

От
"Hiroshi Inoue"
Дата:
> -----Original Message-----
> From: Hiroshi Inoue [mailto:Inoue@tpf.co.jp]
> > But, considering the fact that DEFAULT can be something reaaly 
> > complex, like
> > function that does a lot of things, it may be better to have the 
> > constraints
> > checked at the end of transaction, like
> > 
> > BEGIN;
> > ALTER TABLE T1 ADD COLUMN C1 TEXT NOT NULL;
> 
> Isn't 'iNITIALLY DEFERRED' needed ?
> ALTER TABLE T1 ADD COLUMN C1 TEXT NOT NULL INITIALLY DEFERRED;
> 
> > UPDATE T1 SET C1='MYDEFAULTVALUE';
> > COMMIT;
> >
> 
> It seems more reasonable than standard.
> But is it worth breaking SQL standard ?
>

Seems I was wrong. It's not so good.
Current spec to reject NOT NULL/DEFAULT for new column
isn't so bad and ADD CONSTRAINT feature is much more
important. How about the following ?

BEGIN;
ALTER TABLE T1 ADD COLUMN C1 TEXT;
UPDATE T1 SET C1='MYDEFAULTVALUE';
ALTER TABLE T1 ADD CONSTRAINT CHECK C1 NOT NULL;
COMMIT;

Regards.

Hiroshi Inoue
Inoue@tpf.co.jp