On 30 Sep 2016, at 2:13pm, Ertan Küçükoğlu <[email protected]> wrote:

> My application is normally working on DatabaseA. I run an attach command for
> DatabaseB like:
> Attach DatabaseB as source
> 
> After a successful attach. If I want to select something from
> DatabaseB-Table3 is it enough to call below SQL?
> Select * from Table3
> 
> Or, even if there is no table names that overlap on each other, Do I still
> need to run something as follows:
> Select * from source.Table3

Use the second one: "source.Table3".  It may be possible that the first one 
works but it is not documented and may stop working in later versions of SQLite.

I think you're asking because you have a number of different databases to 
attach and you don't want to have to write extra code to access each one.  (And 
you cannot use the tablename as a parameter.)

Don't forget that you can attach a different database with the same schema 
name.  So sometimes you might do

ATTACH DATABASE 'daily-20160915.sqlite' AS 'thatday'

then you can do

DETACH DATABASE 'thatday';
ATTACH DATABASE 'daily-20160916.sqlite' AS 'thatday'

Also, you can refer to the connection's database with a name.  It is called 
'main'.  And you can also attach it to its own connection and refer to it using 
a different name.

Simon.
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to