Re: Set NOT NULL error - Mailing list pgsql-novice

From Andreas Kretschmer
Subject Re: Set NOT NULL error
Date
Msg-id 20111121075949.GA6133@tux
Whole thread Raw
In response to Set NOT NULL error  (Michael Rowan <mike.rowan@internode.on.net>)
List pgsql-novice
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°

pgsql-novice by date:

Previous
From: Michael Rowan
Date:
Subject: Set NOT NULL error
Next
From: James Long
Date:
Subject: Grant privs on entire database, not table-by-table-by-table