加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-12 19:37:19 所属栏目:百科 来源:网络整理
导读:转自:http://blog.sina.com.cn/s/blog_77eab95f0101t8qp.html 查询 table , type 段是 'table' , name 段是 table 的名字 ,so: select name from sqlite_master where type='table' order by name; 查询 indices , type 段是 'index',name 是 index 的名

转自: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',nameindex的名字,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

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

NameDescription

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

nameThe object’s name

tbl_nameThe table the object is associated with

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

sqlThe object’s SQL definition (DDL)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读