Обсуждение: Alter table .. Add primary key

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

Alter table .. Add primary key

От
Rod Taylor
Дата:
When doing an alter table .. add primary key operation on columns which
are not marked as null, would it be appropriate to mark the primary key
columns not null?

This follows with create table auto-marking columns null for primary
keys.


rbt=# \d ar    Table "public.ar"Column | Type | Modifiers 
--------+------+-----------col    | r    | 

rbt=# alter table ar add primary key (col);
ERROR:  Existing attribute "col" cannot be a PRIMARY KEY because it is
not marked NOT NULL

-- 
Rod Taylor <rbt@rbt.ca>