Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id DB14C47718A for ; Thu, 13 Jun 2002 18:10:19 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id A700747712C for ; Thu, 13 Jun 2002 17:13:19 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.4/8.11.4) with ESMTP id g5DLDGb29719; Thu, 13 Jun 2002 17:13:16 -0400 (EDT) To: Charlie Toohey Cc: pgsql-sql@postgresql.org Subject: Re: serial column vs. explicit sequence question In-reply-to: <20020613200344.1B97A476B74@postgresql.org> References: <20020613200344.1B97A476B74@postgresql.org> Comments: In-reply-to Charlie Toohey message dated "Thu, 13 Jun 2002 13:03:45 -0700" Date: Thu, 13 Jun 2002 17:13:16 -0400 Message-ID: <29716.1024002796@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200206/188 X-Sequence-Number: 8153 Charlie Toohey writes: > A better solution would seem to use a sequence explicitly, rather than a id > column of type serial. I would obtain the id value from the sequence, and > then insert this id into the master table and into the detail table. Yup. But there's no need to change how you create the id column; serial is just fine, since all it is is a sequence and a DEFAULT nextval('foo'). You just do something like select nextval('name-of-id-columns-sequence') into $masterid; insert into master(id, ...) values ($masterid, ...); insert into detail ... $masterid ...; rather than letting the default expression do it for you. regards, tom lane