From: | Vineet Deodhar <vineet(dot)deodhar(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | auto-increment field : in a simple way |
Date: | 2012-10-11 07:04:30 |
Message-ID: | CAP5=7oo5DirtJU6s8XpxMq8Cfhg0xnW7T8KnZE_FpTwaCfWMrw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I wish to know regarding auto-increment field.
I learn that the required table definition would be something like --
CREATE TABLE tablename (
colname SERIAL
);
For more granular control over the size of field, I need to do the following---
CREATE SEQUENCE user_id_seq;
CREATE TABLE user (
user_id smallint NOT NULL DEFAULT nextval('user_id_seq')
);
ALTER SEQUENCE user_id_seq OWNED BY user.user_id;
I am not pinpointing MySQL v/s Postgres; but since I am accustomed to
using simply "AUTOINCREMENT" in MySQL,
I find this a bit cumbersome procedure.
1] Is there any simpler way of doing this?
2] Whether the development team has this point in their TO DO list for
future release of postgres?
Thanks,
Vineet
From | Date | Subject | |
---|---|---|---|
Next Message | Scott Marlowe | 2012-10-11 07:26:59 | Re: auto-increment field : in a simple way |
Previous Message | F. BROUARD / SQLpro | 2012-10-11 06:43:44 | Re: moving from MySQL to pgsql |