On 2 Aug 2017, at 5:35pm, Nico Williams <[email protected]> wrote:
> On Wed, Aug 02, 2017 at 04:56:34PM +0100, Simon Slavin wrote: >> Can someone explain ? > > Think of sequences as non-deterministic functions. (They are actually > deterministic, but using hidden state, so from the engine's perspective > they are non-deterministic.) > > They make it easy to have N tables with the same rowid namespace, for > example. So you could do something like: > > CREATE SEQUENCE foo START WITH 0 INCREMENT BY 5; > CREATE TABLE t1 (rowid integer primary key default (next_serial(foo)), ...); > CREATE TABLE t2 (rowid integer primary key default (next_serial(foo)), ...); > CREATE TABLE t3 (rowid integer primary key default (next_serial(foo)), ...); Okay, I understand that. Thanks, Nico. So the reason I didn’t understand the need for sequences is that someone who had been using SQLite for a long time would never come up with the concept. It’s just not needed. You’d just create individual tables, each with their own AUTOINC key as normal, then key into them using a VIEW or FOREIGN KEY. The problem solved by SEQUENCEs never arises. This gives us a problem with Peter’s original question, because it seems unlike that implmenting sequences with SQLite is common enough that we have a ready solution. Simon. _______________________________________________ sqlite-users mailing list [email protected] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

