From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
---|---|
To: | javier garcia - CEBAS <rn001(at)cebas(dot)csic(dot)es> |
Cc: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: add a constraint to specify NOT NULL values |
Date: | 2003-05-20 14:55:29 |
Message-ID: | 20030520075222.W64750-100000@megazone23.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, 20 May 2003, javier garcia - CEBAS wrote:
> Hi all;
>
> How could I add a constraint to specify that a column can't be null? I've
> tried a lot of sintaxis of the style of:
>
> (the table is "pluviometria", and the column is "year")
>
>
> ALTER TABLE pluviometria ALTER year CONSTRAINT NOT NULL;
> ALTER TABLE pluviometria.year CONSTRAINT NOT NULL;
> ALTER pluviometria.year ADD CONSTRAINT NOT NULL;
> ALTER TABLE pluviometria ALTER COLUMN cod_variable SET NOT NULL;
The last form should work if you're using a new enough version (assuming
cod_variable is the column you want to not null - you used year in the
other examples), what version are you using?
A fallback position might be something like
ALTER TABLE pluviometria ADD CHECK (column is not null);
From | Date | Subject | |
---|---|---|---|
Next Message | nelma | 2003-05-20 14:58:46 | cursor |
Previous Message | Ben Joyce | 2003-05-20 14:49:35 | pg newbie stumped on sequences! |