Thread: Set NOT NULL error

Set NOT NULL error

From
Michael Rowan
Date:
This command run from the SQL window of pgAdmin3 results in an error:

In the table vehicle there is a column maker_id
There is no data in the table, it is newly created.

ALTER TABLE vehicle ADD CONSTRAINT maker_id SET NOT NULL;

ERROR: syntax error at or near "SET"

AKAICS thats a direct copy of the required command in the PostgreSQL 9.1 docs, so I wonder what provokes the error?


Michael Rowan
mike.rowan@internode.on.net

11 Kingscote Street
ALBERTON
South Australia 5014

tel 618 8240 3993




Re: Set NOT NULL error

From
Andreas Kretschmer
Date:
Michael Rowan <mike.rowan@internode.on.net> wrote:

> This command run from the SQL window of pgAdmin3 results in an error:
>
> In the table vehicle there is a column maker_id
> There is no data in the table, it is newly created.
>
> ALTER TABLE vehicle ADD CONSTRAINT maker_id SET NOT NULL;
>
> ERROR: syntax error at or near "SET"

wrong syntax, use instead:

test=# create table foo1(id int);
CREATE TABLE
Time: 0,623 ms
test=*# alter table foo1 alter column id set not null;
ALTER TABLE
Time: 0,334 ms

Regards

Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect.                              (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly."   (unknown)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°