pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: prinsarian@zonnet.nl
To: pgsql-sql@postgresql.org
Subject: Re: Auto Increment
Date: Mon, 22 Oct 2001 07:30:16 GMT
Message-ID: <3bd3ca9f.5654630@news.amc.uva.nl> (raw)
References: <9r0enc$h9v$1@news.tht.net>

On Mon, 22 Oct 2001 12:06:21 +0530, "Mayuresh Kadu"
<mayureshk@aftek.com> wrote:

>hi all,
>
>could anyone tell me how to make a primary key to AUTO INCREMENT. The
>document is not exactly very explainatory about it :)
>
>Thankx in advance ...
>
>
>
>Mayuresh
>
>

Try first creating a sequence and then using the sequence as a default
value in your table:


-- STEP 1: create sequence
create sequence mytableid_seq;

-- STEP 2: create table
create table mytable (
  id int default nextval ('mytableid_seq'),
  anyvalue varchar
  primary key (id));



view thread (27+ messages)  latest in thread

Message-ID: <3bd3ca9f.5654630@news.amc.uva.nl>
Permalink:  ../3bd3ca9f.5654630@news.amc.uva.nl/
Also on:    postgresql.org/message-id/3bd3ca9f.5654630@news.amc.uva.nl

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: prinsarian@zonnet.nl
  Subject: Re: Auto Increment
  In-Reply-To: <3bd3ca9f.5654630@news.amc.uva.nl>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox