Thread: Auto_Increment

Auto_Increment

From
Stephane Pinel
Date:
What is the pgsql equivalent keyword for the MySQL auto_increment
keyword ?

Thanks.

Regards.

Stephane


Re: Auto_Increment

From
Peter Childs
Date:
On Saturday 09 August 2003 15:44, Stephane Pinel wrote:
> What is the pgsql equivalent keyword for the MySQL auto_increment
> keyword ?

serial. (For the short answer) To be quick. ie

CREATE table x (a serial);

or

CREATE SEQUENCE a_seq;
ALTER TABLE x ALTER a SET DEFAULT next_val('a_seq');


>
> Thanks.
>
> Regards.
>
> Stephane
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
>                http://archives.postgresql.org


Peter Childs

Re: Auto_Increment

From
Ron Johnson
Date:
On Sat, 2003-08-09 at 09:44, Stephane Pinel wrote:
> What is the pgsql equivalent keyword for the MySQL auto_increment
> keyword ?
>
> Thanks.

http://www.postgresql.org/
http://www.postgresql.org/docs/
http://www.postgresql.org/docs/7.3/static/index.html
http://www.postgresql.org/docs/7.3/static/datatype.html
http://www.postgresql.org/docs/7.3/static/datatype.html#DATATYPE-SERIAL

--
+---------------------------------------------------------------+
| Ron Johnson, Jr.        Home: ron.l.johnson@cox.net           |
| Jefferson, LA  USA                                            |
|                                                               |
| "Man, I'm pretty.  Hoo Hah!"                                  |
|    Johnny Bravo                                               |
+---------------------------------------------------------------+



Re: Auto_Increment

From
Jason Hihn
Date:
SERIAL

Though, there is a small change - this will create a sequence for you, and
in MySQL you could get the value that it assigned.

In Posgres you have to begin a transaction, insert the record, select
CURRVAL('sequence_name'); {read result} then commit the transaction.

> -----Original Message-----
> From: pgsql-novice-owner@postgresql.org
> [mailto:pgsql-novice-owner@postgresql.org]On Behalf Of Stephane Pinel
> Sent: Saturday, August 09, 2003 10:44 AM
> To: pgsql-novice@postgresql.org
> Subject: [NOVICE] Auto_Increment
>
>
> What is the pgsql equivalent keyword for the MySQL auto_increment
> keyword ?
>
> Thanks.
>
> Regards.
>
> Stephane
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
>                http://archives.postgresql.org
>