1、创建打开数据库
sqlite3 arm.db 创建数据库arm.db
2、建立表
create table table_name (col1_name type,col2_name type,col3_name type);
3、动态添加表字段
alter table table_name add col_name type;
4、动态删除表字段
例如:表test 中含有字段 id ,datatime ,record要删除record列
create temporary table table_name (id integer primary key ,datatime int);
insert into table_name select id ,datatime form test;或者insert into table_name select into *from test;
drop table test;
create table test (id integer primary key ,datatime int);
insert into test select *form table_name;或者insert into test select id ,datatime formtable_name
drop table table_name;
5、显示数据库中所有表的名称
select name from sqlite_master where type ='table' order by name;
6、显示数据库中所有表名中含有S02的名称
select name form sqlite_master where (type ='table' )and (name like 's02%');
7、插入数据
insert into table_name column_name values(值);
8、修改某个字段的值
update table_name set column_name =值 where (条件);
附:
1、 sqlite3 sql命令必须依据;结尾来完成数据查询
2、sql下用于删除指定列 alter table table_name drop column col_name;