X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id 516E330FA09 for ; Thu, 26 Jun 2003 12:46:12 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 53541-01 for ; Thu, 26 Jun 2003 09:46:01 -0300 (ADT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id 0B80230F180 for ; Thu, 26 Jun 2003 09:46:01 -0300 (ADT) Received: (qmail 7069 invoked by uid 500); 26 Jun 2003 12:49:29 -0000 Date: Thu, 26 Jun 2003 07:49:29 -0500 From: Bruno Wolff III To: Dani Oderbolz Cc: pgsql-sql@postgresql.org Subject: Re: Change the behaviour of the SERIAL "Type" Message-ID: <20030626124929.GA7040@wolff.to> Mail-Followup-To: Dani Oderbolz , pgsql-sql@postgresql.org References: <3EFAE7A6.9070904@ecologic.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3EFAE7A6.9070904@ecologic.de> User-Agent: Mutt/1.5.4i X-Archive-Number: 200306/295 X-Sequence-Number: 14053 On Thu, Jun 26, 2003 at 14:31:34 +0200, Dani Oderbolz 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.