| От | Tom Lane |
|---|---|
| Тема | Re: Message about not null in ALTER TABLE |
| Дата | |
| Msg-id | 28347.1011732945@sss.pgh.pa.us обсуждение |
| Ответ на | Message about not null in ALTER TABLE (Alvaro Herrera <alvherre@atentus.com>) |
| Список | pgsql-bugs |
Alvaro Herrera <alvherre@atentus.com> writes:
> However, there is no way to add a NOT NULL constraint to an existing
> column in a table, so the error message is misleading.
Sure there is:
regression=# create table test (a int);
CREATE
regression=# alter table test add column b int not null;
ERROR: Adding NOT NULL columns is not implemented.
Add the column, then use ALTER TABLE ADD CONSTRAINT.
regression=# alter table test add column b int;
ALTER
regression=# alter table test add constraint bnotnull check (b notnull);
ALTER
regression=#
It'd be nice to have more ALTER TABLE variants implemented, but it's
not true that you can't get the functionality nohow...
regards, tom lane
В списке pgsql-bugs по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера