cannot add "not null" to an existing table - Mailing list pgsql-general

From marco ghidinelli
Subject cannot add "not null" to an existing table
Date
Msg-id 20021021160909.GA8352@ufficio.chiocciolina.net
Whole thread Raw
List pgsql-general
hello,
i can't be able to add a constraint to a table.

example:

alter table mytable add primary key (id);

-- i get the error: Existing attribute "id" cannot be a PRIMARY KEY because
-- it is not marked NOT NULL
--
-- but at this point i cannot be able to add the constraint not null to the
-- column id.
--
-- i tried:
alter table mytable alter column id set not null;
-- ERROR:  parser: parse error at or near "not"

alter table mytable set not null (id);
-- ERROR:  parser: parse error at or near "set"

alter table mytable add not null (id);
-- ERROR:  parser: parse error at or near "not"

----------------------------------------
note that i must alter an existing table, or copying and modifying an
existing table.

postgresql 7.2.3 - debian package.
postgresql 7.2.2 - debian package.

any idea?

--
BOFH excuse #321:

Scheduled global CPU outage

pgsql-general by date:

Previous
From: Juan Jose Comellas
Date:
Subject: VACUUM FULL not working with persistent connections in v7.2
Next
From: "Owen Jacobson"
Date:
Subject: Automatic insertion on insertion on another table