pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruno Wolff III <bruno@wolff.to>
To: Dani Oderbolz <oderbolz@ecologic.de>
Cc: pgsql-sql@postgresql.org
Subject: Re: Change the behaviour of the SERIAL "Type"
Date: Thu, 26 Jun 2003 07:49:29 -0500
Message-ID: <20030626124929.GA7040@wolff.to> (raw)
In-Reply-To: <3EFAE7A6.9070904@ecologic.de>
References: <3EFAE7A6.9070904@ecologic.de>

On Thu, Jun 26, 2003 at 14:31:34 +0200,
  Dani Oderbolz <oderbolz@ecologic.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.



view thread (8+ messages)  latest in thread

Message-ID: <20030626124929.GA7040@wolff.to>
Permalink:  ../20030626124929.GA7040@wolff.to/
Also on:    postgresql.org/message-id/20030626124929.GA7040@wolff.to

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: bruno@wolff.to, oderbolz@ecologic.de
  Subject: Re: Change the behaviour of the SERIAL "Type"
  In-Reply-To: <20030626124929.GA7040@wolff.to>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox