Re: [sqlite] PK and rowid

2006-10-11 Thread Kees Nuyt
On Wed, 11 Oct 2006 00:19:28 -0700 (PDT), you wrote:

>Hi,
>   
>  If I declare my column as,  "uniqId integer primary key", 
>  now if I say something like,
>  select * from tbl1 where uniqId=x;
>   
>  Will the uniqId be same as rowid, making my table look ups
>  faster as I am using row id only. If not whats the way to
>  assign my uniqId to the row id so that my lookups would be
>  faster.

http://www.sqlite.org/lang_createtable.html by drh>
"Specifying a PRIMARY KEY normally just creates a UNIQUE index
on the corresponding columns. However, if primary key is on a
single column that has datatype INTEGER, then that column is
used internally as the actual key of the B-Tree for the table.
This means that the column may only hold unique integer values.
(Except for this one case, SQLite ignores the datatype
specification of columns and allows any kind of data to be put
in a column regardless of its declared datatype.) 

If a table does not have an INTEGER PRIMARY KEY column, then the
B-Tree key will be a automatically generated integer. The B-Tree
key for a row can always be accessed using one of the special
names "ROWID", "OID", or "_ROWID_". This is true regardless of
whether or not there is an INTEGER PRIMARY KEY. An INTEGER
PRIMARY KEY column can also include the keyword AUTOINCREMENT.
The AUTOINCREMENT keyword modified the way that B-Tree keys are
automatically generated. Additional detail on automatic B-Tree
key generation is available separately."



>  ...
>  Chetana.

I hope this helps.
-- 
  (  Kees Nuyt
  )
c[_]

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



AW: [sqlite] PK and rowid

2006-10-11 Thread Martin Pfeifle
uniqId is the same as rowid, 
so you will get the same execution plans for ...where rowid=x and  ... where 
uniqId=x.


- Ursprüngliche Mail 
Von: chetana bhargav <[EMAIL PROTECTED]>
An: sqlite-users@sqlite.org
Gesendet: Mittwoch, den 11. Oktober 2006, 09:19:28 Uhr
Betreff: [sqlite] PK and rowid


Hi,
   
  If I declare my column as,  "uniqId integer primary key", now if I say 
something like,
  select * from tbl1 where uniqId=x;
   
  Will the uniqId be same as rowid, making my table look ups faster as I am 
using row id only. If not whats the way to assign my uniqId to the row id so 
that my lookups would be faster.
   
   
  ...
  Chetana.


-
Do you Yahoo!?
Everyone is raving about the  all-new Yahoo! Mail.






___ 
Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: 
http://mail.yahoo.de

[sqlite] PK and rowid

2006-10-11 Thread chetana bhargav
Hi,
   
  If I declare my column as,  "uniqId integer primary key", now if I say 
something like,
  select * from tbl1 where uniqId=x;
   
  Will the uniqId be same as rowid, making my table look ups faster as I am 
using row id only. If not whats the way to assign my uniqId to the row id so 
that my lookups would be faster.
   
   
  ...
  Chetana.


-
Do you Yahoo!?
 Everyone is raving about the  all-new Yahoo! Mail.