sqlite 获取数据库所有表名和字段名

来源:互联网 发布:淘宝vip 编辑:程序博客网 时间:2024/05/02 06:46

转自:http://blog.sina.com.cn/s/blog_77eab95f0101t8qp.html


查询tabletype 段是'table'name段是table的名字, so:

select name from sqlite_master where type='table' order by name;

 

查询indicestype段是'index', name index的名字,tbl_nameindex所拥有的table的名字

 

通过以下语句可查询出某个表的所有字段信息

PRAGMA table_info([tablename])

 

如果在程序中你可以通过 sqlite_master  表得到所有表的信息。

sqlite> select type, name, tbl_name from sqlite_master order by type;

type|name|tbl_name

index|sqlite_autoindex_t1_1|t1

index|sqlite_autoindex_numtable_1|numtable

table|t1|t1

table|numtable|numtable

table|test|test

table|sqlite_stat1|sqlite_stat1

table|MailLabel|MailLabel

sqlite>

 

 

sqlite_master  结构如下

SQLite Master Table Schema

-----------------------------------------------------------------

Name                       Description

-----------------------------------------------------------------

type          The object’s type (table, index, view, trigger)

name          The object’s name

tbl_name      The table the object is associated with

rootpage      The object’s root page index in the database (where it begins)

sql           The object’s SQL definition (DDL)


0 0
原创粉丝点击