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


当前回答

在SQLite数据库中查看表有几个步骤:

列出数据库中的表: .tables 列出表格的外观: . schema的表 打印整个表格: SELECT * FROM tablename; 列出所有可用的SQLite提示命令: .help

其他回答

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

”。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);

要列出表格,您还可以这样做:

SELECT name FROM sqlite_master
WHERE type='table';

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

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

sqlite3> ATTACH database.sqlite as "attached"

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

$sqlite3 database.sqlite
sqlite3> .dump

我使用这个查询来获得它:

SELECT name FROM sqlite_master WHERE type='table'

在iOS中使用:

NSString *aStrQuery=[NSString stringWithFormat:@"SELECT name FROM sqlite_master WHERE type='table'"];