tachyon has asked for the wisdom of the Perl Monks concerning the following question:
I have a Webmail app that uses a database backend for its address book, task list, calendar etc. Currently it runs against MySQL and uses MySQL's non ANSI standard AUTO INCREMENT feature to generate the sequence for the id column primary key:
$sql =<<SQL; CREATE TABLE address_book ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, title VARCHAR(20), first_name VARCHAR(30), last_name VARCHAR(30), [blah] PRIMARY KEY (id) ) SQL
There are of course a number of ways of generating a unique primary key like CREATE SEQUENCE. What I would like is suggestions of the most portable way short of creating a table called primary_keys with columns for the tables that hold the next primary key for each table and doing atomic read/updates on these.
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Generating portable SQL primary key sequences
by lachoy (Parson) on Dec 07, 2002 at 14:54 UTC | |
by iburrell (Chaplain) on Jun 22, 2004 at 22:07 UTC | |
|
Re: Generating portable SQL primary key sequences
by adrianh (Chancellor) on Dec 07, 2002 at 16:52 UTC | |
|
Re: Generating portable SQL primary key sequences
by FamousLongAgo (Friar) on Dec 07, 2002 at 13:34 UTC | |
by tachyon (Chancellor) on Dec 07, 2002 at 15:13 UTC | |
by dragonchild (Archbishop) on Jun 22, 2004 at 20:55 UTC | |
by adamk (Chaplain) on Oct 04, 2003 at 05:15 UTC |