Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id EE27163322C for ; Sat, 10 Oct 2009 16:01:01 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 31793-06 for ; Sat, 10 Oct 2009 19:00:46 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.ecpi.com (mail.ecpi.com [64.128.16.3]) by mail.postgresql.org (Postfix) with ESMTP id 9026C6328F9 for ; Sat, 10 Oct 2009 16:00:49 -0300 (ADT) Received: (qmail 8223 invoked by uid 89); 10 Oct 2009 19:00:35 -0000 Received: from unknown (HELO paulsen.homeip.net) (64.128.19.172) by mail4.ecpi.com with SMTP; 10 Oct 2009 19:00:35 -0000 Received: by paulsen.homeip.net (Postfix, from userid 1000) id 6781D11CB11; Sat, 10 Oct 2009 14:00:47 -0500 (CDT) From: Robert Paulsen To: Tom Lane Subject: Re: ERROR: null value in column "id" violates not-null constraint Date: Sat, 10 Oct 2009 14:00:46 -0500 User-Agent: KMail/1.9.1 Cc: pgsql-sql@postgresql.org References: <200910101056.24051.robert@paulsenonline.net> <17323.1255200405@sss.pgh.pa.us> In-Reply-To: <17323.1255200405@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200910101400.47182.robert@paulsenonline.net> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200910/43 X-Sequence-Number: 33242 On Saturday 10 October 2009 1:46 pm, Tom Lane wrote: > Robert Paulsen writes: > > I have a database with a sequence field as a primary key in a table and > > can no longer insert data into it as it gets the subject error message. > > Does the table actually have a default for id anymore? (Try looking > at it with psql's \d command.) pwvault=# \d vault Table "public.vault" Column | Type | Modifiers ----------+-------------------------+--------------- id | integer | not null archived | boolean | default false service | character varying(256) | not null category | character varying(16) | userid | character varying(256) | not null passwd | character varying(256) | not null url | character varying(4096) | notes | text | Indexes: "vault_pkey" PRIMARY KEY, btree (id) So no default for id. What should it be? Something like one of this? default nextval('vault_id_seq') pwvault=# \d vault_id_seq Sequence "public.vault_id_seq" Column | Type ---------------+--------- sequence_name | name last_value | bigint increment_by | bigint max_value | bigint min_value | bigint cache_value | bigint log_cnt | bigint is_cycled | boolean is_called | boolean