:-D

one more question :

if i create primary key on my table and then import the data (assuming i
used transactions) will my import be faster or slower vs the case where  i
import the data first and then create key (foreign key ??) and index the
table.

the point is that i need my import to be faster. i have 3890660 rows to
import and row van be up to 50M large, so it's taking a pretty long time



thnx




Kees Nuyt wrote:
> 
> On Thu, 19 Mar 2009 02:54:34 -0700 (PDT), baxy77bax
> <b...@hi.htnet.hr> wrote:
> 
>>
>>hi my question is : if i create table that contains primary key like;
>>
>>create table TEST (field1 varchar not null primary key);
>>
>>do i need to create index on it or not?
> 
> No, the primary key implies an index will be created
> automatically.
> 
>>and is it better to create table with a primary key and then import data
in
>>it or create table without a key , import data and then just create index
on
>>the table. (which is faster- or should i ask which is the fastest way to
>>import data in the table?)
> 
> You can't add a primary key afterwards. 
> 
> The best way is to create the table with the primary key and
> then insert records sorted by the primary key field.
> For speed you also have to wrap the INSERT statements in a
> transaction (BEGIN; INSERT; ......... INSERT; COMMIT;).
> 
> If you want to use the .import command of the SQLite command
> line tool, you would sort the import file beforehand on the
> primary key column.
> 
>>then if i create proper table , is it advisable to order data by 
>>column with primary key on it or data with index on it.
> 
> In your case (with a primary key on a text column) that
> won't make a difference, I think.
> 
>>thank you
> -- 
>   (  Kees Nuyt
>   )
> c[_]
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> 
> 
:-D:-D
-- 
View this message in context: 
http://www.nabble.com/is-primary-key-already-indexed---tp22596778p22600402.html
Sent from the SQLite mailing list archive at Nabble.com.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to