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??
相关问题
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- Difference between Types.INTEGER and Types.NULL in
- php PDO::FETCH_ASSOC doesnt detect select after ba
- Bulk update SQL Server C#
Try
PRAGMA table_info(table-name);
http://www.sqlite.org/pragma.html#schema
To show all tables, use
To show all rows, I guess you can iterate through all tables and just do a SELECT * on each one. But maybe a DUMP is what you're after?
Use
.help
to check for available commands.This command would show all tables under your current database.
The easiest way to do this is to open the database directly and use the
.dump
command, rather than attaching it after invoking the SQLite 3 shell tool.So... (assume your OS command line prompt is $) instead of
$sqlite3
:From your OS command line, open the database directly:
The
.tables
, and.schema
"helper" functions don't look into ATTACHed databases: they just query theSQLITE_MASTER
table for the "main" database. Consequently, if you usedthen you need to do
Note that temporary tables don't show up with
.tables
either: you have to listsqlite_temp_master
for that:To list the tables you can also do: