Re: Re: DB Sequences

From: Date: Thu, 18 Jul 2002 15:21:44 +0000
Subject: Re: Re: DB Sequences
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-1929@lists.php.net to get a copy of this message
On Thu, 18 Jul 2002, robert janeczek wrote: > > The sentence "You can have more than one sequence for all your tables" > > could be read like "There is no need to have one sequence for each > > table, you can have just one for all your tables". > > i don`t think thats what alan wanted to get. he asked about optimalization: > storing all (or some) sequences in one table. possible problem is - how > would you get the sequence by name, if it is a row in table - you would have > to use id of some kind to determine which sequence you want to access. > sequence names wouldn`t look pretty then :] > > rash Simple, my friends. Here is Alan's proposition in pseudo-sql: CREATE TABLE sequences ( name varchar(30) primary key, value int, increment int ); When you want to access a sequence do: SELECT value, increment FROM sequences WHERE name = $seqname; and you have your value. Now update: UPDATE sequences SET value = value + increment WHERE name = $seqname Of course, you would need to make these two operations a transaction so that nobody could get a same sequence number, but you see the idea. I'm working on sequence support for DBA, and this is how I plan in implementing it. - Brent

« previous php.pear.general (#1929) next »