Received: from news.tht.net (news.hub.org [216.126.91.242]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f9MGbMP27863 for ; Mon, 22 Oct 2001 12:37:22 -0400 (EDT) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.4/8.11.4) id f9M7UNP19041 for pgsql-sql@postgresql.org; Mon, 22 Oct 2001 03:30:23 -0400 (EDT) (envelope-from news) From: prinsarian@zonnet.nl (Arian Prins) X-Newsgroups: comp.databases.postgresql.sql Subject: Re: Auto Increment Date: Mon, 22 Oct 2001 07:30:16 GMT Organization: Academic Medical Center, The Netherlands Lines: 28 Message-ID: <3bd3ca9f.5654630@news.amc.uva.nl> References: <9r0enc$h9v$1@news.tht.net> X-Complaints-To: usenet@news.surfnet.nl X-Newsreader: Forte Free Agent 1.21/32.243 Cache-Post-Path: sphere.amc.uva.nl!unknown@rilke.amc.uva.nl X-Cache: nntpcache 2.4.0b2 (see http://www.nntpcache.org/) To: pgsql-sql@postgresql.org X-Archive-Number: 200110/313 X-Sequence-Number: 5266 On Mon, 22 Oct 2001 12:06:21 +0530, "Mayuresh Kadu" 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));