What SQL can be used to list the tables, and the rows within those tables in a SQLite database file - once I have attached it with the ATTACH
command on the SQLite 3 command line tool?
Answer
The .tables
, and .schema
"helper" functions don't look into ATTACHed databases: they just query the SQLITE_MASTER
table for the "main" database. Consequently, if you used
ATTACH some_file.db AS my_db;
then you need to do
SELECT name FROM my_db.sqlite_master WHERE type='table';
Note that temporary tables don't show up with .tables
either: you have to list sqlite_temp_master
for that:
SELECT name FROM sqlite_temp_master WHERE type='table';
No comments:
Post a Comment