Обсуждение: Auto_Increment
What is the pgsql equivalent keyword for the MySQL auto_increment keyword ? Thanks. Regards. Stephane
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
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 | +---------------------------------------------------------------+
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
>