pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Pham, Thinh <tpham@mail.priority.net>
To: 'Rodrigo Bernardo Pimentel' <rbp@pobox.com>
To: pgsql-sql@postgreSQL.org
Subject: RE: [SQL] auto_increment?
Date: Thu, 21 Oct 1999 11:31:11 -0500
Message-ID: <551413BBBB03D111BF880060B01AACCE139FD0@home.priority.net> (raw)

How about using "serial" in the place of "auto_increment"? such as

CREATE TABLE table (
id       serial,
name     text,
email    text);

I guess you already know this but i thought i'd just mention it anyway,
using "table" for table name wouldn't work ;-)
Thinh


> -----Original Message-----
> From: Rodrigo Bernardo Pimentel [mailto:rbp@pobox.com]
> Sent: Thursday, October 21, 1999 10:45 AM
> To: pgsql-sql@postgreSQL.org
> Subject: [SQL] auto_increment?
> 
> 
> 	Hi.
> 	I recently had to port a script from using Postgres to MySQL. 
> 	In Postgres, when I have to use a unique id, I create a sequence
> and call nextval('sequence') each time I insert a new line in 
> the table.
> 	MySQL doesn't have sequences (as far as the 
> documentation shows).
> So I had to look for an alternative. I found an atribute 
> "auto_increment"
> which seems pretty interesting. If I do
> CREATE TABLE table (
> id       int4 primary key auto_increment,
> name     text,
> email    text);
> 
> 	It automatically assigns the next value when I do
> INSERT INTO table (nome, email) values ('My name', 
> 'me@somewhere.com');
> 
> 	When I noticed MySQL didn't have sequences, I cursed a 
> lot. When I 
> found this out, though, I kept wondering if Postgres also had 
> it, but I
> couldn't find any mention in the documentation. Does anyone 
> know if something
> similar exists? Am I doing thins the hard way? Is there any 
> other way of 
> automagically getting unique ids?
> 	TIA,
> 
> 
> 		rbp
> 
> ______________________________________________________________
> __________
>  Rodrigo Bernardo Pimentel     <rbp@pobox.com>|   GPG KeyID: 81F85A48
>  LinuxSP           <http://www.linuxsp.org.br;|      Fingerprint:
>  AirGeeks            <http://www.airgeeks.org;|7E62 9CA2 C95B 
> FC86 B334
> _____________ Debian Linux User ______________|203E C011 2E4D 
> 81F8 5A48
> 
> ************
> 



view thread (27+ messages)  latest in thread

Message-ID: <551413BBBB03D111BF880060B01AACCE139FD0@home.priority.net>
Permalink:  ../551413BBBB03D111BF880060B01AACCE139FD0@home.priority.net/
Also on:    postgresql.org/message-id/551413BBBB03D111BF880060B01AACCE139FD0@home.priority.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tpham@mail.priority.net, rbp@pobox.com
  Subject: RE: [SQL] auto_increment?
  In-Reply-To: <551413BBBB03D111BF880060B01AACCE139FD0@home.priority.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox