2.简单使用安装说明:SQLite version 2.8.17
Enter ".help" for instructions
sqlite>
我这是2.8.17版本 按照其建议使用命令:.help 出现下列信息
.databases List names and files of attached databases
.dump ?TABLE? ... Dump the database in a text format
.echo ON|OFF Turn command echo on or off
.exit Exit this program
.explain ON|OFF Turn output mode suitable for EXPLAIN on or off.
.header(s) ON|OFF Turn display of headers on or off
.help Show this message
.indices TABLE Show names of all indices on TABLE
.mode MODE Set mode to one of "line(s)", "column(s)",
"insert", "list", or "html"
.mode insert TABLE Generate SQL insert statements for TABLE
.nullvalue STRING Print STRING instead of nothing for NULL data
.output FILENAME Send output to FILENAME
.output stdout Send output to the screen
.prompt MAIN CONTINUE Replace the standard prompts
.quit Exit this program
.read FILENAME Execute SQL in FILENAME
.schema ?TABLE? Show the CREATE statements
.separator STRING Change separator string for "list" mode
.show Show the current values for various settings
.tables ?PATTERN? List names of tables matching a pattern
.timeout MS Try opening locked tables for MS milliseconds
.width NUM NUM ... Set column widths for "column" mode
4.向表中插入数据 我插了三条记录
INSERT INTO user(id,name,age)values(1,'felay',22);
sqlite> INSERT INTO user(id,name,age)values(2,'felay1',23);
sqlite> INSERT INTO user(id,name,age)values(3,'felay2',24);
5.查询数据 select * from user;结果如图所示
sqlite> select * from user;
1|felay|22
2|felay1|23
3|felay2|24
6.更新数据 update user set age=(age+10); 结果如图
sqlite> select * from user;
1|felay|32
2|felay1|33
3|felay2|34
7.删除数据delete from user where age=32;,结果如图
1|felay|32
2|felay1|33
3|felay2|34
sqlite> delete from user where age=32;
sqlite> select * from user;
2|felay1|33
3|felay2|34
sqlite>
好了上面就是sqlite的最基本的crud操作了。然后说下常用的命令
1..tables-------查看当前数据库中的所有表 如.tables,因为我的数据库中只有一个user表因此显示如图
sqlite> .tables
user
2..help------帮助我们查看常用的命令技巧,结果如图
sqlite> .help
.databases List names and files of attached databases
.dump ?TABLE? ... Dump the database in a text format
.echo ON|OFF Turn command echo on or off
.exit Exit this program
.explain ON|OFF Turn output mode suitable for EXPLAIN on or off.
.header(s) ON|OFF Turn display of headers on or off
.help Show this message
.indices TABLE Show names of all indices on TABLE
.mode MODE Set mode to one of "line(s)", "column(s)",
"insert", "list", or "html"
.mode insert TABLE Generate SQL insert statements for TABLE
.nullvalue STRING Print STRING instead of nothing for NULL data
.output FILENAME Send output to FILENAME
.output stdout Send output to the screen
.prompt MAIN CONTINUE Replace the standard prompts
.quit Exit this program
.read FILENAME Execute SQL in FILENAME
.schema ?TABLE? Show the CREATE statements
.separator STRING Change separator string for "list" mode
.show Show the current values for various settings
.tables ?PATTERN? List names of tables matching a pattern
.timeout MS Try opening locked tables for MS milliseconds
.width NUM NUM ... Set column widths for "column" mode
所有常用命令和解释都在help命令中,大家可以看详细文档。