Received: from beastie.cyp (p405-105.ppp.get2net.dk [195.82.214.105]) by hub.org (8.9.3/8.9.3) with ESMTP id TAA18065 for ; Tue, 7 Sep 1999 19:29:52 -0400 (EDT) (envelope-from hroi@get2net.dk) Received: from get2net.dk (herbie [192.168.1.2]) by beastie.cyp (8.9.2/8.9.2/beastie) with ESMTP id BAA45406 for ; Wed, 8 Sep 1999 01:28:28 +0200 (CEST) (envelope-from hroi@get2net.dk) Sender: hroi@get2net.dk Message-ID: <37D59F84.115F1790@get2net.dk> Date: Tue, 07 Sep 1999 23:28:04 +0000 From: Hroi Sigurdsson Organization: 1210 Lovers X-Mailer: Mozilla 4.61 [en] (X11; I; Linux 2.2.12 i586) X-Accept-Language: en, da, is, sv MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: DEFAULT confusion Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hello postgresql'ers (how do you pronounce that?). Suppose i have the following sequence, table and index: CREATE SEQUENCE stuff_seq; CREATE TABLE stuff ( id INTEGER DEFAULT NEXTVAL('stuff_seq') NOT NULL, name TEXT, number INTEGER ); CREATE UNIQUE INDEX stuff_id ON tabel(id); Then to properly insert rows i have to INSERT INTO tabel VALUES (NEXTVAL('tabel_seq'), "sometext", 123); I can't just INSERT INTO tabel VALUES (NULL, "something", 123); Then what is the point of the DEFAULT clause? In other words: How do I get away with not specifying anything for id? And how (if possible/recommendable) do I force the id value to be nothing but NEXTVAL('stuff_seq'), ie. not just an arbitrary number? In short I want to emulate MySQL's way of doing CREATE TABLE( id INT NOT NULL AUTO_INCREMENT, name TEXT, int INT, UNIQUE(id) ); I hope I made myself sufficiently clear. Thank you for your time. PS. Where can I get more information about the REFERENCES keyword and when will it be fully working in Postgres? PPS. Are there any books out there that cover Postgresql? -- Hroi Sigurdsson hroi@ninja.dk