Re: Auto-incrementing field - Mailing list pgsql-novice

From denis@coralindia.com
Subject Re: Auto-incrementing field
Date
Msg-id 00a501c23789$1e0fe2c0$0232a8c0@coralindia.com
Whole thread Raw
In response to Auto-incrementing field  ("Jim Steil" <jim.steil@customcall.com>)
List 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'
CREATE
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..

Denis


----- Original Message -----
From: "Jim Steil" <jim.steil@customcall.com>
To: <pgsql-novice@postgresql.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
used
> 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@postgresql.org so that your
> message can get through to the mailing list cleanly


pgsql-novice by date:

Previous
From: denis@coralindia.com
Date:
Subject: Re: Trigger question
Next
From: James Kelty
Date:
Subject: Changing Database Name