Re: How to do auto numbering on INT column

From: Chris Mair <chrisnospam(at)1006(dot)org>
To: Junkone <junkone1(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to do auto numbering on INT column
Date: 2006-08-10 17:44:48
Message-ID: 1155231888.5893.28.camel@dell.home.lan
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


> HI
> I have a simple table created using PGAdmin III. How do i do a auto
> numbering on a column SYMBOL_ID?
> My table is
> CREATE TABLE "SYMBOL"
> (
> "SYMBOL_ID" int4 NOT NULL,
> "SYMBOL2EXCHANGE" int2 NOT NULL,
> "SYMBOL_ALIAS" text[],
> "RELATED_SYMBOLS_OTHER_EXCHANGES" int8[],
> "SYMBOL_NAME" text,
> "COMPANY_NAME" text,
> "SYMBOL2SECTOR" int2,
> "SYMBOL2INDUSTRY" int4,
> "STOCK_SUMMARY" text
> )

Use column type SERIAL, or, if you want to fine tune things,
use sequences:
http://www.postgresql.org/docs/8.1/static/sql-createsequence.html
(in fact, SERIAL does define a sequence behind the scenes for you).

Bye, Chris.

--

Chris Mair
http://www.1006.org

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Shoaib Mir 2006-08-10 19:08:57 Re: High available solution
Previous Message gpap 2006-08-10 17:36:18 High available solution