From: | Bruno Wolff III <bruno(at)wolff(dot)to> |
---|---|
To: | Dani Oderbolz <oderbolz(at)ecologic(dot)de> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Change the behaviour of the SERIAL "Type" |
Date: | 2003-06-26 12:49:29 |
Message-ID: | 20030626124929.GA7040@wolff.to |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Thu, Jun 26, 2003 at 14:31:34 +0200,
Dani Oderbolz <oderbolz(at)ecologic(dot)de> wrote:
>
> It was written for MySQL, which can take NULL and then assign an
> auto_increment.
> However, in PostgreSQL I am getting problems, because it would not let
> me insert NULL
> into a NOT NULL column (which is perfectly sensible from my point of view).
> But as the author has also left out the column list in the insert, its
> really tedious to change
> the code.
You can use the keyword DEFAULT instead of NULL and it will do what you
want.
> This way, there would be no possibility to circumvent the Value which
> comes from the Sequence.
You can use a unique constraint to enforce uniqueness.
> Is there a way to change SERIAL this way?
Well you can certainly write your own trigger to do this.
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Huxton | 2003-06-26 13:09:01 | Re: Join or Where? |
Previous Message | Dani Oderbolz | 2003-06-26 12:31:34 | Change the behaviour of the SERIAL "Type" |