.databasesmain: C:\Users\test\test.dbsqlite> 创建表 sqlite> create table _person (_id integer pri。android原创|sqlite3命令行操作db巩固。" />

android原创|sqlite3命令行操作db巩固

创建数据库

C:\Users\test>sqlite3 test.db SQLite version 3.22.0 2018-01-22 18:45:57 Enter ".help" for usage hints.

查看数据库
sqlite> .databases main: C:\Users\test\test.db sqlite>

创建表
sqlite> create table _person (_id integer primary key autoincrement,_name varchar(20),age integer,address text);

插入数据
sqlite> insert into _person(_name,age,address) values("test",22,"xiangy"); sqlite> insert into _person(_name,age,address) values("test1",23,"xiangy1"); sqlite> insert into _person(_name,age,address) values("test2",24,"xiangy2"); sqlite> insert into _person(_name,age,address) values("test3",25,"xiangy3"); sqlite> insert into _person(_name,age,address) values("test4",26,"xiangy4"); sqlite> select * from _person; 1|test|22|xiangy 2|test1|23|xiangy1 3|test2|24|xiangy2 4|test3|25|xiangy3 5|test4|26|xiangy4

更新表
sqlite> update _person set age=38,address="chengd" where _name="test1"; sqlite> select * from _person; 1|test|22|xiangy 2|test1|38|chengd 3|test2|24|xiangy2 4|test3|25|xiangy3 5|test4|26|xiangy4

更新表
sqlite> update _person set age=39,address="chengd2" where _id=2; sqlite> select * from _person; 1|test|22|xiangy 2|test1|39|chengd2 4|test3|25|xiangy3 5|test4|26|xiangy4

删除数据
sqlite> delete from _person where _id=3; sqlite> select * from _person; 1|test|22|xiangy 2|test1|38|chengd 4|test3|25|xiangy3 5|test4|26|xiangy4

    推荐阅读