sqlite的一些用法
发布时间:2020-12-12 20:19:03 所属栏目:百科 来源:网络整理
导读:1、获取数据库文件中表相关的信息 从系统表sqlite_master获取 系统表sqlite_master: type( 类型 ) 、name ( 名称 ) 、tbl_name ( 表名称 ) 、root_page ( 引导页面 ) 、sql ( 创建表的SQL语句 ) 获取表名称的SQL语句 select tbl_name from sqlite_master wh
1、获取数据库文件中表相关的信息
从系统表sqlite_master获取
系统表sqlite_master:
type(
类型
)
、name
(
名称
)
、tbl_name
(
表名称
)
、root_page
(
引导页面
)
、sql
(
创建表的SQL语句
)
获取表名称的SQL语句
select tbl_name from
sqlite_master where type = 'table'
获取指定表中的字段名称:
无法直接使用SQL语句获取,只能从创建表的SQL语句中进行分析,用来获取字段名称
select sql from
sqlite_master where type = 'table' and tbl_name = table_name
注意:分析sql语句,要把双引号、换行符、回车符去掉,字段之间用逗号分隔。
2、添加表字段
alter table table_name add
column
col_name data_type;
例如:alter table vul_detail add COLUMN vul_id interge;
备注:
不支持删除表字段;
删除表字段:
altertable
table_name
dropcolumn
col_name
;
3、sqlite的系统表
sqlite_master、
sqlite_temp_master、sqlite_sequence、sqlite_stat1
当数据库文件的表存在主键时,才会有后面的两个表 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |