SQLITE3 常用操作
发布时间:2020-12-13 00:22:08 所属栏目:百科 来源:网络整理
导读:!-- @page { margin: 0.79in } PRE.western { font-family: "Liberation Serif" } PRE.cjk { font-family: "Liberation Serif" } P { margin-bottom: 0.08in } -- SQLITE3 常用操作 收藏 1.建立数据库在sqlite安装的目录/usr/bin下,(其实在任何目录都可以
<!-- @page { margin: 0.79in } PRE.western { font-family: "Liberation Serif" } PRE.cjk { font-family: "Liberation Serif" } P { margin-bottom: 0.08in } --> SQLITE3 常用操作 收藏 1.建立数据库 在sqlite安装的目录/usr/bin下,(其实在任何目录都可以输入下面语句) sqlite3 sensordata.db 该语句新建一个名为sensordata的 数据库,并进入该数据库,在该目录下生成sensordata.db文件,即为数据库文件 2.建立表 create table sensortable1(one varchar(10),two smallint); CREATE TABLE sensortable1(ID smallint primary key,Source smallint,Dest smallint,Accel_x smallint,Accel_y smallint,Accel_z smallint,Temperature smallint,Humidity smallint,BrdLight smallint,InfraLight smallint); CREATE TABLE sensortable1(ID INTEGER PRIMARY KEY AUTOINCREMENT,InfraLight smallint); 3.插入数据 insert into sensortable1 values('hello!',10); insert into sensortable1 values(null,2048,37500,34000,100,100); insert into sensortable1 values(1,100); 4.显示表的各列名称 .header on 5.显示数据 select * from sensortable1; select * from sensortable1 where ID >5; 6.显示当前数据库中的表 .tables 7.删除数据表中的数据 删除所有 delete from sensortable1; 条件删除 delete from sensortable1 where name <20; 8.删除数据表 drop table sensortable1; 9.退出sqlite3 .exit 10.强制退出 control+D 更多详细操作参考http://www.sqlite.org/sqlite.html 11.对齐显示 .mode column select * from sensortable1; 12.显示创建表的语句 .schema Show the CREATE statements (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |