Re: Set NOT NULL error

From: Andreas Kretschmer <akretschmer(at)spamfence(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Set NOT NULL error
Date: 2011-11-21 07:59:49
Message-ID: 20111121075949.GA6133@tux
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Michael Rowan <mike(dot)rowan(at)internode(dot)on(dot)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°

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message James Long 2011-11-22 03:57:03 Grant privs on entire database, not table-by-table-by-table
Previous Message Michael Rowan 2011-11-21 03:32:33 Set NOT NULL error