读书人

sqlite中怎么查询数据库中存在的所有表

发布时间: 2012-06-05 13:54:06 作者: rapoo

sqlite中如何查询数据库中存在的所有表?
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_masterWHERE type='table'ORDER BY name; 

读书人网 >其他数据库

热点推荐