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


当前回答

”。Schema " commando将列出可用的表及其行,通过显示用于创建上述表的语句:

sqlite> create table_a (id int, a int, b int);
sqlite> .schema table_a
CREATE TABLE table_a (id int, a int, b int);

其他回答

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

看起来你需要遍历sqlite_master表,就像这样:

SELECT * FROM dbname.sqlite_master WHERE type='table';

然后用SELECT或类似的方法手动遍历每个表以查看行。

. dump和. schema命令似乎根本看不到数据库。

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

select name
from sqlite_master 
where type='table'

union all 

select name 
from sqlite_temp_master 
where type='table'

.tables和.schema“助手”函数不查找ATTACHed数据库:它们只查询SQLITE_MASTER表以查找“主”数据库。因此,如果你使用

ATTACH some_file.db AS my_db;

然后你需要做

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

注意,临时表也不会用.tables显示:你必须列出sqlite_temp_master:

SELECT name FROM sqlite_temp_master WHERE type='table';

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

.fullschema

查看所有的create语句。