It's particularly valuable when you want to run queries across databases.

INSERT INTO main.table
SELECT *
FROM newdata.table;

Also if it's possible for you to segment out your data to multiple databases
but normally only work with one of them, then you can increase performance
and concurrency for those times when you only need to work with one
database, but then have the ability to attach databases when you need all
the data together.

Most if not all database engines have similar functionality, but syntax and
functionality differs in each.  SQLite syntax is easiest to use of the ones
I've used (MSSQL, Access, Sybase ASE, Oracle).

HTH,

Sam 


-------------------------------------------
We're Hiring! Seeking a passionate developer to join our team building Flex
based products. Position is in the Washington D.C. metro area. If interested
contact [EMAIL PROTECTED]
 
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jason Tudor
Sent: Thursday, February 07, 2008 5:21 PM
To: sqlite-users@sqlite.org
Subject: [sqlite] Why attach databases?

I have been playing around with attaching databases.  I'm not sure what the
point is.
Assume that I have two databases with the same schema, say db1 and db2, and
I attach them to one connection.

In order to get the count from a particular table, I could do the following:

SELECT COUNT id FROM main.table UNION
SELECT COUNT id FROM db2.table

I would then step through the result and add the two values to get a total
count.


If I have two separate connections, I could run two queries and add the
results.
Is there a speed difference?

In general, what is the benefit of attaching databases verses maintaining
multiple connections?

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

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

Reply via email to