什么SQL可以用来列出表,以及在SQLite数据库文件中的这些表中的行-一旦我已经附加了它与SQLite 3命令行工具上的ATTACH命令?


当前回答

试试PRAGMA table_info(table-name); http://www.sqlite.org/pragma.html#schema

其他回答

试试PRAGMA table_info(table-name); http://www.sqlite.org/pragma.html#schema

使用.help检查可用的命令。

.table

这个命令将显示当前数据库下的所有表。

最简单的方法是直接打开数据库并使用.dump命令,而不是在调用SQLite 3 shell工具后附加它。

所以…(假设你的操作系统命令行提示符是$)而不是$sqlite3:

sqlite3> ATTACH database.sqlite as "attached"

从你的操作系统命令行,直接打开数据库:

$sqlite3 database.sqlite
sqlite3> .dump

对于SQLite 3的最新版本,您可以发布:

.fullschema

查看所有的create语句。

通过union all,将所有表合并到一个列表中。

select name
from sqlite_master 
where type='table'

union all 

select name 
from sqlite_temp_master 
where type='table'