Skip site navigation (1) Skip section navigation (2)

Re: Auto-incrementing field

From: denis(at)coralindia(dot)com
To: "Jim Steil" <jim(dot)steil(at)customcall(dot)com>,<pgsql-novice(at)postgresql(dot)org>
Subject: Re: Auto-incrementing field
Date: 2002-07-30 05:22:34
Message-ID: 00a501c23789$1e0fe2c0$ (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
Yes.. Try SERIAL datatype.

test=# Create Table test (my_auto SERIAL,Name text);
NOTICE:  CREATE TABLE will create implicit sequence 'test_my_auto_seq' for
SERIAL column 'test.my_auto'
NOTICE:  CREATE TABLE/UNIQUE will create implicit index 'test_my_auto_key'
for table 'test'
test=# insert into test(name) values ('Denis');
INSERT 13170208 1
test=# select * from test;
 my_auto | name
       1 | Denis

(1 row)

Note : It implicitely creates SEQUENCE and associate it with the field. But
if you drop the table, you need to drop the SEQUENCE manually.. it does not
drop it automatically..


----- Original Message -----
From: "Jim Steil" <jim(dot)steil(at)customcall(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Sent: Saturday, July 27, 2002 1:19 AM
Subject: [NOVICE] Auto-incrementing field

> Is there a data type in PostgreSQL that will 'auto-increment'?  I have
> this in MS SQL Server in the past and would like to continue to do so with
> PostgreSQL.  Thanks for any help...
> -Jim
> Jim Steil
> CustomCall Data Systems
> (608) 274-3009
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly

In response to

pgsql-novice by date

Next:From: James KeltyDate: 2002-07-30 15:48:50
Subject: Changing Database Name
Previous:From: denisDate: 2002-07-30 05:10:27
Subject: Re: Trigger question

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group