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$0232a8c0@coralindia.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
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'
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(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
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(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
From | Date | Subject | |
---|---|---|---|
Next Message | James Kelty | 2002-07-30 15:48:50 | Changing Database Name |
Previous Message | denis | 2002-07-30 05:10:27 | Re: Trigger question |