Re: [sqlite] Sequential numbers

2014-06-30 Thread James K. Lowden
On Tue, 24 Jun 2014 21:02:22 +0100 Dave Wellman dwell...@ward-analytics.com wrote: 2) Assuming that my processing follows this pattern: empty table T1 completely, insert a number of rows, insert/select from T1 into T2. On the 'select' processing will the 'rowid' ** always ** start at 1?

Re: [sqlite] Sequential numbers

2014-06-26 Thread Hick Gunter
-Ursprüngliche Nachricht- Von: RSmith [mailto:rsm...@rsweb.co.za] Gesendet: Mittwoch, 25. Juni 2014 21:54 An: sqlite-users@sqlite.org Betreff: Re: [sqlite] Sequential numbers On 2014/06/25 21:38, Dave Wellman wrote: Hi Petite, Many thanks fo rthsuggestion, it works a treat!. Hi

Re: [sqlite] Sequential numbers

2014-06-26 Thread Rob Golsteijn
Hi Dave,   You can of course also calculate a new sequence number based on the row ids. Just count the number of records with a smaller or equal rowid. This way it doesn't matter if rowid starts at 1 or if there are any gaps in the range.   Example:   CREATE TABLE aaa (i, seqnr); INSERT INTO

Re: [sqlite] Sequential numbers

2014-06-26 Thread E.Pasma
Op 26 jun 2014, om 10:32 heeft Rob Golsteijn het volgende geschreven: Hi Dave, You can of course also calculate a new sequence number based on the row ids. Just count the number of records with a smaller or equal rowid. This way it doesn't matter if rowid starts at 1 or if there are any

Re: [sqlite] Sequential numbers

2014-06-26 Thread Roman Fleysher
Example: CREATE TABLE aaa (i, seqnr); INSERT INTO aaa VALUES(10,NULL); INSERT INTO aaa VALUES(20,NULL); INSERT INTO aaa VALUES(50,NULL); INSERT INTO aaa VALUES(30,NULL); INSERT INTO aaa VALUES(20,NULL); UPDATE aaa SET seqnr=(SELECT count() FROM aaa smaller where smaller.rowid =

Re: [sqlite] Sequential numbers

2014-06-25 Thread David Wellman
: [sqlite] Sequential numbers On Jun 24, 2014, at 10:47 PM, Dave Wellman dwell...@ward-analytics.com wrote: I need the values to be sequential. Well. if your data set is as small as you mentioned (20 records or less). you could roll your own numbering schema with the simple expedient

Re: [sqlite] Sequential numbers

2014-06-25 Thread Dave Wellman
: 3917021 Registered in England and Wales. -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Petite Abeille Sent: 24 June 2014 21:57 To: General Discussion of SQLite Database Subject: Re: [sqlite] Sequential numbers On Jun 24

Re: [sqlite] Sequential numbers

2014-06-25 Thread RSmith
On 2014/06/25 21:38, Dave Wellman wrote: Hi Petite, Many thanks fo rthsuggestion, it works a treat!. Hi Simon, Thanks for the thoughts but in this particular processing that is not going to happen (delete a few rows). In this processing we always empty the table completely before re-populating

[sqlite] Sequential numbers

2014-06-24 Thread Dave Wellman
Hi all, I have some rows in a table (not very many, typically less than 20) and I want to generate a unique, sequential number for each row. In another dbms I've used a row_number function (amongst others) to achieve this but I can't see anything with equivalent functionality in sqlite3. My

Re: [sqlite] Sequential numbers

2014-06-24 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 24/06/14 13:02, Dave Wellman wrote: I have some rows in a table (not very many, typically less than 20) and I want to generate a unique, sequential number for each row. http://www.sqlite.org/autoinc.html Roger -BEGIN PGP SIGNATURE-

Re: [sqlite] Sequential numbers

2014-06-24 Thread Dave Wellman
Database Subject: Re: [sqlite] Sequential numbers -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 24/06/14 13:02, Dave Wellman wrote: I have some rows in a table (not very many, typically less than 20) and I want to generate a unique, sequential number for each row. http://www.sqlite.org

Re: [sqlite] Sequential numbers

2014-06-24 Thread Petite Abeille
On Jun 24, 2014, at 10:47 PM, Dave Wellman dwell...@ward-analytics.com wrote: I need the values to be sequential. Well… if your data set is as small as you mentioned (20 records or less)… you could roll your own numbering schema with the simple expedient of attaching a trigger to your tables

Re: [sqlite] Sequential numbers

2014-06-24 Thread Simon Slavin
On 24 Jun 2014, at 9:47pm, Dave Wellman dwell...@ward-analytics.com wrote: Included in that page is the following: Note that monotonically increasing does not imply that the ROWID always increases by exactly one. One is the usual increment. However, if an insert fails due to (for example)