As it happens the monthly sales figures for 2007 are in a table called "gross_sales" in the database loaded as "main" and the figures for 2006 are in a table also called "gross_sales" which can be found in the attached database "lastyear". In the following example we wish to compare this year gross sales by month for a business against those of last year. Sqlite> PRAGMA lastyear.table_info(gross_sales) PRAGMA database_alias.table_info( table_name) PRAGMA table_info( table_name) /* Will work if the table name is not duplicated in another database */ While there is no command to list the names of the tables in an attached database, if you do know which tables are there, you can get the table structure with the SQLite specific PRAMGMA table_info statement. Consequently you have to know the names of the attached database tables in order to refer to them. Sqlite> ATTACH 'sales2006.sqlite' AS lastyear Īn unfortunate problem is that dot commands such as ".tables ", ".dump ", ".schema " will only list objects of the database loaded as main not those of the attached databases. Attached databases may have table names that are identical to the database loaded as "main" or to other attached databases but a table cannot be created that duplicates a currently loaded table.Ĭ:\DOCUME~1\COLINR~1\LOCALS~1\Temp\etilqs_Fr4rkeXfxA2wWVBoĪTTACH ' drive/path/database_name' AS database_alias Changes may be made to the schema and data contained in the attached databases. Tables from different databases can be included in the same query. SQLite allows the use of as many as ten attached databases in addition to the database loaded as "main". Working With Attached Databases in SQLite
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |