Browse Sqlite for Multiple Databases

Is it possible to create a VIEW database in the Sqlite database (not a temporary view) to which other databases are linked? A view must have access to data from all databases through joined tables.

+5
source share
1 answer

No, the view should be temporary, otherwise an error will occur:

sqlite> create view view1 as select * from db2.foo union select * from main.foo;
Error: view view1 cannot reference objects in database db2
sqlite> create temp view view1 as select * from db2.foo union select * from main.foo;
sqlite> select * from view1;
...

This makes sense because the temporary view is part of an automatically created database tempthat exists only for the current process.

EDIT:

You can list temporary tables and views (all stored in an automatically created database temp) as follows:

sqlite> .headers on
sqlite> select * from sqlite_temp_master;
type|name|tbl_name|rootpage|sql
view|view1|view1|0|CREATE VIEW view1 as select * from db2.foo union select * from main.foo

To view only listings:

select * from sqlite_temp_master where type='view';
+7
source

All Articles