Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+3 votes
2 views
in SQL by (20.3k points)

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?

1 Answer

+4 votes
by (40.7k points)
edited by

The "helper" functions like .schema and .tables, don't look into ATTACHED databases. For the "main" database, they just query the SQLITE_MASTER table.

Want to learn SQL from basics! Here's the right video for you on SQL provided by Intellipaat:

Thus, if you used

ATTACH some_file.db1 AS my_db1;

then you need to do this:

SELECT name FROM my_db1.sqlite_master WHERE type='table';

Note: Temporary tables don't show up with .tables either.

Have a look at this video to understand the purpose of using TEMPORARY TABLE.

The temporary tables are used to keep temporary data. The benefit of using temporary tables is that they will be deleted when the current client session terminates.

 SELECT name FROM sqlite_temp_master WHERE type='table';

Related questions

0 votes
1 answer
0 votes
1 answer
asked Dec 12, 2020 in SQL by Appu (6.1k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Oct 5, 2019 in SQL by Tech4ever (20.3k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...