微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

sqlite中如何查询数据库中存在的所有表?转自:http://topic.csdn.net/u/20081231/16/6aee6233-32c2-4f20-a3d7-0cb154974ce4.

sqlite中如何查询数据库中存在的所有表?

请指教!!!


官方文档就有。

http://www.sqlite.org/faq.html

(7) How do I list all tables/indices contained in an sqlite database

If you are running the sqlite3 command-line access program you can type ".tables" to get a list of all tables. Or you can type ".schema" to see the complete database schema including all tables and indices. Either of these commands can be followed by a LIKE pattern that will restrict the tables that are displayed.

From within a C/C++ program (or a script using Tcl/Ruby/Perl/Python bindings) you can get access to table and index names by doing a SELECT on a special table named "sqlITE_MASTER". Every sqlite database has an sqlITE_MASTER table that defines the schema for the database.

sql code
SELECT name FROM sqlite_master
WHERE type='table'
ORDER BY name;




如果你在sqlite行命令下,你可以直接使用 .tables 或 .schema 命令来得到完整的数据库包括表s和索引s. 这两个命令支持匹配符。
如果在其它宿主程序中例如 C/C++等,你可以从一个特殊的表 "sqlITE_MASTER" 得到类似的信息

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐