Re: serial autoincrement and related table

From: Milos Prudek <prudek(at)bvx(dot)cz>
To: Paul Thomas <paul(at)tmsl(dot)demon(dot)co(dot)uk>
Cc: "pgsql-general (at) postgresql (dot) org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: serial autoincrement and related table
Date: 2004-05-17 11:52:55
Message-ID: 40A8A797.4000708@bvx.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


> If you want PostgreSQL to populate your idmember field with the next
> value from the sequence, you need to specify the keyword DEFAULT as its
> value or omit it from the INSERT list of coulumns (this assumes you have

I do omit it.

> DEFAULT nextval('members_idmember_seq') defined on the idmember column).

I use CREATE TABLE "members" (idmember" SERIAL PRIMARY KEY, ...);

> Should be :
>
> Cmd = "SELECT currval('members_idmember_seq');"

Ah, thanks for the shorter syntax.

> Remember that there's no such thing as auto-increment fields in
> PostgreSQL - they are SEQUENCES.

I know.

So, it's the best or reasonable practice(TM), isn't it?

--
Milos Prudek

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2004-05-17 11:56:02 Re: serial autoincrement and related table
Previous Message Paul Thomas 2004-05-17 11:31:33 Re: serial autoincrement and related table