Received: from omelete.that.com.br (omelete.that.com.br [200.220.70.3]) by hub.org (8.9.3/8.9.3) with ESMTP id LAA79893 for ; Thu, 21 Oct 1999 11:45:37 -0400 (EDT) (envelope-from rbp@that.com.br) Received: (from uucp@localhost) by omelete.that.com.br (8.8.8/8.8.8/Debian/GNU) id NAA25746 for ; Thu, 21 Oct 1999 13:45:19 -0200 Received: from laranjada.that.com.br(192.168.120.2) via SMTP by tortilla.that.com.br, id smtpda25734; Thu Oct 21 13:44:53 1999 Received: from rbp by laranjada.that.com.br with local (Exim 2.05 #1 (Debian)) id 11eKOb-0006p7-00; Thu, 21 Oct 1999 13:44:53 -0200 Date: Thu, 21 Oct 1999 13:44:52 -0200 From: Rodrigo Bernardo Pimentel To: pgsql-sql@postgresql.org Subject: auto_increment? Message-ID: <19991021134452.E25861@pobox.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95.3i Sender: Rodrigo Pimentel 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 | GPG KeyID: 81F85A48 LinuxSP | Fingerprint: AirGeeks |7E62 9CA2 C95B FC86 B334 _____________ Debian Linux User ______________|203E C011 2E4D 81F8 5A48