[sqlite] Generating new rowid algo

2008-03-10 Thread B V, Phanisekhar
All, I wanted to know the algorithm used by sqlite to generate the new rowid. Assume there can be N distinct rowid's possible, now insert N records, followed by random deletion of some records. Now what rowid will be assigned to a new row that is added? Regards, Phanisekhar

RE: [sqlite] sqlite 3.x lock states

2007-10-17 Thread B V, Phanisekhar
> A database is in the EXCLUSIVE state if one of the processes has an > EXCLUSIVE lock. Only *one* process at a time can hold an EX- CLUSIVE > lock. The process holding the EXCLUSIVE lock is currently writing to > the database file. Every other process must hold *no* lock. No other >

RE: [sqlite] Re: Merge two rows/records

2007-10-08 Thread B V, Phanisekhar
Hi Daan, You can make the columns (a, b) unique across (a, b), but not separately unique; by that whenever you are trying to insert a row with same (a, b) combination it will give an error and at that time you can update the column values c and d. I hope this will solve your problem.

RE: [sqlite] select COUNT (DISTINCT column1, column2) from table?

2007-09-25 Thread B V, Phanisekhar
,month); If it is not a real sample and you have string data you may concatenate or something like this. Hope this helps. Regards, Dennis Xeepe Phone Solution Team http://en.xeepe.com mailto:[EMAIL PROTECTED] sip:[EMAIL PROTECTED] -----Original Message- From: B V, Phanisekhar [mailto:[E

RE: [sqlite] select COUNT (DISTINCT column1, column2) from table?

2007-09-25 Thread B V, Phanisekhar
-Original Message- From: Simon Davies [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 25, 2007 4:09 PM To: sqlite-users@sqlite.org Subject: Re: [sqlite] select COUNT (DISTINCT column1, column2) from table? On 25/09/2007, B V, Phanisekhar <[EMAIL PROTECTED]> wrote: > Hi Simon, .

RE: [sqlite] select COUNT (DISTINCT column1, column2) from table?

2007-09-25 Thread B V, Phanisekhar
COUNT (DISTINCT column1, column2) from table? On 25/09/2007, B V, Phanisekhar <[EMAIL PROTECTED]> wrote: . . > Assume you have a following data: > > matchNo, year, month > > 34 2007 9 > > 27 2006 5 > > 26 2006 5 > > Now di

[sqlite] select COUNT (DISTINCT column1, column2) from table?

2007-09-25 Thread B V, Phanisekhar
Assume I have a database. Maintable (matchNo integer, year INTEGER, month INTEGER) I have to find the count of distinct year, month combinations in which matches were played. I tried the query select COUNT (DISTINCT column1, column2) from table but this gives an error. I would like to know

RE: [sqlite] How is the Index table in sqlite?

2007-09-13 Thread B V, Phanisekhar
Sorry for the spelling mistake in the subject. Regards, Phani -Original Message- From: B V, Phanisekhar Sent: Thursday, September 13, 2007 3:53 PM To: sqlite-users@sqlite.org Subject: [sqlite] How is the Index stable in sqlite? Database configuration: Tables: Create table maintable

[sqlite] How is the Index stable in sqlite?

2007-09-13 Thread B V, Phanisekhar
Database configuration: Tables: Create table maintable(column1 INTEGER, column2 INTEGER, column3 INTEGER). Indices: Create index column1idx on maintable (column1); How does the index table look like in sqlite? c-r 1-3 3-4 3-6 3-7 5-1 5-8 6-2 Or c-r... 1->3

RE: [sqlite] (select *) VS (select column1, column2 ...)

2007-09-03 Thread B V, Phanisekhar
f you use "select col1, col2, col3". It can't know what you're going to do after the query is executed, so it has to prepare for any possibility. So, yes, there's a difference. Yes, selecting only the columns you need is more efficient. No, I don't think you'll notice much of a diffe

[sqlite] (select *) VS (select column1, column2 ...)

2007-08-31 Thread B V, Phanisekhar
Assume I have a table with 40 columns. I would like to know the difference between Select * from table Select column1, column2, column3 from table While doing SQLITE3_PREPARE, will both take same amount of time? While doing SQLITE3_STEP, will both take same amount of time?

RE: [sqlite] How to generate Unique ID?

2007-08-31 Thread B V, Phanisekhar
to generate Unique ID? On Thu, 30 Aug 2007 13:06:38 +0100, "Simon Davies" <[EMAIL PROTECTED]> wrote: > On 30/08/2007, B V, Phanisekhar <[EMAIL PROTECTED]> wrote: >> Simon, >>Yeah you can term the problem like that. Can't I use the >> function

RE: [sqlite] How to generate Unique ID?

2007-08-31 Thread B V, Phanisekhar
Unique ID? Why do you have a unique primary key as an integer to hold your other unique integer? Why not just use the unique integer as a primary key? If you want to have a limit on the maximum unique ID you can store your next to allocate and next to replace keys in another table. B V

RE: [sqlite] How to generate Unique ID?

2007-08-30 Thread B V, Phanisekhar
, 2007 4:35 PM To: sqlite-users@sqlite.org Subject: Re: [sqlite] How to generate Unique ID? On 30/08/2007, B V, Phanisekhar <[EMAIL PROTECTED]> wrote: > Simon, > > > Without knowing your design, it looks like you wish to be able to > > determine type from the id. This is cre

RE: [sqlite] How to generate Unique ID?

2007-08-30 Thread B V, Phanisekhar
he answer for my original question. Regards, Phanisekhar -Original Message- From: Simon Davies [mailto:[EMAIL PROTECTED] Sent: Thursday, August 30, 2007 4:13 PM To: sqlite-users@sqlite.org Subject: Re: [sqlite] How to generate Unique ID? On 30/08/2007, B V, Phanisekhar <[EMAIL PROTE

RE: [sqlite] How to generate Unique ID?

2007-08-30 Thread B V, Phanisekhar
? If you use the primary key as your unique identifier, sqlite will take care of locating unused (deleted) ids when the maximum value is reached (according to the documentation; I have not tried it) Rgds, Simon On 30/08/2007, B V, Phanisekhar <[EMAIL PROTECTED]> wrote: > Sreedhar, > > I

RE: [sqlite] How to generate Unique ID?

2007-08-30 Thread B V, Phanisekhar
n the list, it will solve your problem. Best Regards, A.Sreedhar. -Original Message----- From: B V, Phanisekhar [mailto:[EMAIL PROTECTED] Sent: Thursday, August 30, 2007 2:11 PM To: sqlite-users@sqlite.org Subject: [sqlite] How to generate Unique ID? Assume I have a table: Create table YYY (i

[sqlite] How to generate Unique ID?

2007-08-30 Thread B V, Phanisekhar
Assume I have a table: Create table YYY (id Interger PRIMARY KEY, puid Unique integer) Id is the primary key. Puid is an unsque interger, whose values needs to be assigned by the user. Currently my approach is get the maximum value of puid stored in the table; add 1 to it and uses this

[sqlite] sql query required

2007-07-27 Thread B V, Phanisekhar
Suppose I have a table: Create table "yearofbirth INTEGER, Name string" What will be the query to identify how many people were born in different years? The output should contain all the years that are present in the table and the total count corresponding to each entry. Eg: 1901

[sqlite] sorting of blobs

2007-07-18 Thread B V, Phanisekhar
Assume I have an albumtable: create table albumtable (albumid INTEGER PRIMARY KEY, album BLOB); Now I do a query to return the entire albums in the albumtable table in alphabetical order: The instructions for the above query are given below: explain select album from albumtable order

RE: [sqlite] Re: Re: Why "Offset" only not supported?

2007-06-27 Thread B V, Phanisekhar
Thanks Igor & Dennis, > As far as I can tell, LIMIT and OFFSET clauses are not specified in any > version of SQL standard. What is your belief based on that this query is > supported by SQL, and what precisely do you mean by the term "SQL" in > this assertion? I thought limit and offset are

RE: [sqlite] Re: Why "Offset" only not supported?

2007-06-27 Thread B V, Phanisekhar
>> Why Sqlite doesn't support just the use of offset in select >> statements? As such SQL does support the use of offset only, without >> limit. But in case of Sqlite it's not possible to use offset without >> limit. >select * from tableName limit -1 offset 5; >-- or >select * from tableName

RE: [sqlite] Why "Offset" only not supported?

2007-06-27 Thread B V, Phanisekhar
I am using sqlite version 3.3.7 Also what I have noticed is "limit ALL" is not supported. "limit_opt ::=", "limit_opt ::= LIMIT expr", "limit_opt ::= LIMIT expr OFFSET expr", "limit_opt ::= LIMIT expr COMMA expr", expr doesn't contain "ALL".

[sqlite] Why "Offset" only not supported?

2007-06-27 Thread B V, Phanisekhar
Why Sqlite doesn't support just the use of offset in select statements? As such SQL does support the use of offset only, without limit. But in case of Sqlite it's not possible to use offset without limit. Also what is mentioned on website is different from what is there in parser.c file. On

[sqlite] where all indexing is used?

2007-06-26 Thread B V, Phanisekhar
Assume a table "create table if not exists Title (Id INTEGER PRIMARY KEY, Titlename BLOB)" "create unique index if not exists TitleIdx ON Title (Titlename)" For which all queries index "TitleIdx" will be used? * select Titlename from Title order by Titlename *

RE: [sqlite] Step Query

2007-06-18 Thread B V, Phanisekhar
> My question here is do I need to do sqlite3_finalize(pStmt); after > every sqlite3_step() to free all memory allocated by > sqlite3_step().Does calling finalize at end will free all memory > allocated by all steps statements? No you don't need to call sqlite3_finalize after every sqlite3_step.

RE: [sqlite] Can the memory usage of SQLite be adjusted?

2007-06-15 Thread B V, Phanisekhar
<[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > <[EMAIL PROTECTED]> wrote: > > > I completed my analysis of the SQLite database memory usage and I was > > > surprised to find that SQLite consumes so much memory. I ran my test > > > case (creates 31 tables) and found that SQLite

RE: [sqlite] PRAGMA cache_size = 0

2007-06-14 Thread B V, Phanisekhar
>> What exactly happens when I change the cache_size (both increase and >> decrease size)? > A variable is set. It seems this term is a misnomer. What are we achieving by setting this variable? This is what is mentioned in the documentation of SQLITE: PRAGMA cache_size; PRAGMA cache_size =

[sqlite] sqlite3_release_memory

2007-06-14 Thread B V, Phanisekhar
sqlite3_release_memory(int n) internally calls sqlite3pager_release_memory(int n) A negative value of input n implies free as much as you can. Suppose if the no of pages in cache = x. Will all the pages be freed when I call sqlite3_release_memory with a negative argument? If not, then what

[sqlite] PRAGMA cache_size = 0

2007-06-14 Thread B V, Phanisekhar
cache? These are some of the questions for which I am yet to receive the answers. Regards, Phani -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 12, 2007 3:40 PM To: sqlite-users@sqlite.org Subject: Re: [sqlite] PRAGMA cache_size = 0 &quo

RE: [sqlite] PRAGMA cache_size = 0

2007-06-12 Thread B V, Phanisekhar
: Tuesday, June 12, 2007 3:40 PM To: sqlite-users@sqlite.org Subject: Re: [sqlite] PRAGMA cache_size = 0 "B V, Phanisekhar" <[EMAIL PROTECTED]> wrote: > I am yet to get answers for the following questions. > Weiyang Wang correctly answered your question at http://www.mail-ar

RE: [sqlite] PRAGMA cache_size = 0

2007-06-12 Thread B V, Phanisekhar
? Regards, Phani -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 12, 2007 3:40 PM To: sqlite-users@sqlite.org Subject: Re: [sqlite] PRAGMA cache_size = 0 "B V, Phanisekhar" <[EMAIL PROTECTED]> wrote: > I am yet to get answer

RE: [sqlite] PRAGMA cache_size = 0

2007-06-11 Thread B V, Phanisekhar
I am yet to get answers for the following questions. > What happens if I set the cache_size to 0? Will I be able to do any of > update/delete/insert/select operations? > > When I set the cache_size to 0, is there any freeing up of memory by > sqlite? Regards, Phani

[sqlite] PRAGMA cache_size = 0

2007-06-11 Thread B V, Phanisekhar
What happens if I set the cache_size to 0? Will I be able to do any of update/delete/insert/select operations? When I set the cache_size to 0, is there any freeing up of memory by sqlite? Regards, Phani

RE: [sqlite] Re: Re: Does sqlite3_step searches for a row in the table / or some results buffer?

2007-06-07 Thread B V, Phanisekhar
for each row. Regards, Phani -Original Message- From: Igor Tandetnik [mailto:[EMAIL PROTECTED] Sent: Thursday, June 07, 2007 5:28 PM To: SQLite Subject: [sqlite] Re: Re: Does sqlite3_step searches for a row in the table / or some results buffer? B V, Phanisekhar <[EMAIL PROTECTED

RE: [sqlite] Re: Does sqlite3_step searches for a row in the table / or some results buffer?

2007-06-07 Thread B V, Phanisekhar
for a row in the table / or some results buffer? B V, Phanisekhar <[EMAIL PROTECTED]> wrote: > Assume a query > > "select * from table " > > Let there be 10 rows in the table > > Hence there will be 10 rows in the result corresponding to the above > query.

[sqlite] Does sqlite3_step searches for a row in the table / or some results buffer?

2007-06-06 Thread B V, Phanisekhar
Assume a query "select * from table " Let there be 10 rows in the table Hence there will be 10 rows in the result corresponding to the above query. We can get all these 10 rows by calling sqlite3_step 10 times. Assume after 3 sqlite3_step calls, we insert a row into this table. Now after

RE: [sqlite] Re: How to retrieve results in a array?

2007-06-05 Thread B V, Phanisekhar
You can use sqlite3_get_table. This will internally step through each row. Regards, Phani -Original Message- From: Dave Furey [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 23, 2007 4:52 AM To: sqlite-users@sqlite.org Subject: RE: [sqlite] Re: How to retrieve results in a array? Ok,

[sqlite] working of OR operation

2007-05-16 Thread B V, Phanisekhar
Let the database be: Create table if not exists maintable (rowid INTEGER PRIMARY KEY, puid INTEGER) Create Unique Index if not exists puididx on maintable (puid) Assume a query "select rowid from maintable where puid = X OR puid = Y or puid = Z" How will this query work internally? 1 Will it

RE: [sqlite] Re: Re: Order of result of a query?

2007-05-16 Thread B V, Phanisekhar
of a query? On Wed, 2007-05-16 at 11:39 +0530, B V, Phanisekhar wrote: > Igor, > > Assume I have a database of the files/folders. > > Let it be > > Rowid puid > 1 1 > 2 2 > 3 3 > 4 5 > 5 7 > 6 8 > 7 10 > > A

RE: [sqlite] Re: Re: Order of result of a query?

2007-05-16 Thread B V, Phanisekhar
[mailto:[EMAIL PROTECTED] Sent: Tuesday, May 15, 2007 8:13 PM To: SQLite Subject: [sqlite] Re: Re: Order of result of a query? B V, Phanisekhar <[EMAIL PROTECTED]> wrote: > Assume the values in the OR clause, be replaced by some subquery. Then > in such scenarios how will I be able

RE: [sqlite] Re: Order of result of a query?

2007-05-15 Thread B V, Phanisekhar
e] Re: Order of result of a query? B V, Phanisekhar <[EMAIL PROTECTED]> wrote: > Assume the database given below > > mainTable (rowid INTEGER, puid INTEGER) > > Assume main table be > > Rowid Puid > 1 2 > 2 3 > 3

[sqlite] Order of result of a query?

2007-05-15 Thread B V, Phanisekhar
Assume the database given below mainTable (rowid INTEGER, puid INTEGER) Assume main table be Rowid Puid 1 2 2 3 3 4 4 6 5 7 6 8 "select rowid from

[sqlite] SQLITE_ERROR in sqlite3_prepare

2007-05-15 Thread B V, Phanisekhar
Hello all, When I try to prepare the stmt for the query "PRAGMA cache_size = ?" I am getting an SQLITE_ERROR. Whereas it doesn't give error for queries like "select xxx from table where rowed = ?" where xxx is some combination of columns. Regards, Phanisekhar

[sqlite] sqlite3_last_insert_rowid : what will it return if we have more than one table?

2007-05-10 Thread B V, Phanisekhar
Assume I have two tables A and B in the databse. sqlite3_last_insert_rowid will return the rowid of which table? Regards, Phani

RE: [sqlite] INSERT OR REPLACE without new rowid

2007-05-08 Thread B V, Phanisekhar
Hi Trey, Even I was looking for something like this. But I don't think SQL allows you to do this. I didn't get what u said about INSERT OR REPLACE looks good. Regards, Phani -Original Message- From: Trey Mack [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 24, 2007 9:11 PM To:

[sqlite] Is this valid sqlite stmt?

2007-05-02 Thread B V, Phanisekhar
DELETE FROM WHERE rowid = a AND refcount - 1 = 0 IF @@ROWCOUNT = 0 UPDATE SET refcount = refcount - 1 where rowid = a Is conditional statements allowed in sqlite? Regards, Phani

RE: [sqlite] An explanation?

2007-04-26 Thread B V, Phanisekhar
? B V, Phanisekhar wrote: > Thanks for that Info. > > I have another question: > > Assume I have a table given below > "CREATE TABLE IF NOT EXISTS Title(Id INTEGER PRIMARY KEY, TitleName > String)" > "CREATE UNIQUE INDEX IF NOT EXISTS TitleIdx ON Ti

RE: [sqlite] An explanation?

2007-04-26 Thread B V, Phanisekhar
l give even better performance? Regards, Phanisekhar -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, April 26, 2007 3:42 PM To: sqlite-users@sqlite.org Subject: Re: [sqlite] An explanation? "B V, Phanisekhar" <[EMAIL PROTECTED]> wrote

RE: [sqlite] An explanation?

2007-04-26 Thread B V, Phanisekhar
Dennis, How does the index table looks? Assume the main table to be: CREATE TABLE table1 (a INTEGER, b INTEGER) Assume there is an index on column a: CREATE INDEX index1 ON table1 (a); Now let's suppose the entries in table1 be: 10, 91

[sqlite] SQL Close issues

2007-04-16 Thread B V, Phanisekhar
Hi all, Sqlite gives an error "Unable to close due to unfinalised statements" if there are any active VM's while we try to close sqlite. Will there be any error (for eg, memory leak and others) if we don't check the condition and try to close the sqlite? The