我是靠谱客的博主 刻苦唇膏,这篇文章主要介绍Android Sqlite3基本命令Sqlite3命令,现在分享给大家,希望可以做个参考。

Sqlite3命令

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
一、基本操作命令:(系统命令) 1、创建数据库: sqlite3 数据库名 例如:[root@192 ~]# sqlite3 /home/DataBases/user.db 2、显示数据库: .databases 例如:sqlite> .databases 3、创建表:SQL语句以分号“;”结束,敲回车键之后,SQL语句就会执行 sqlite> create table person(id integer primary key,name varchar(10),age integer); 4、显示所有的表和视图: sqlite> .tables 5、显示表结构: sqlite> .schema 【表名】 6、获取指定表的索引列表: sqlite> .indices 【表名】 7、从SQL文件导入数据库: sqlite> .read 【文件名】 8、导出数据库到SQL文件: sqlite> .output 【文件名】 sqlite> .dump sqlite> .output stdout 9、格式化输出数据到CSV格式: sqlite> .output 【文件名.csv】 sqlite> .separator sqlite> .select * from test; sqlite> .output stdout 10、从CSV文件导入数据到表中: sqlite> .import 【文件名.csv】 【表名】 附录: .help 查看帮助说明 .dbinfo 查看数据库信息 11、备份数据库: [root@jovan ~]# sqlite3 【数据库名】 .dump > backup.sql 12、恢复数据库: [root@jovan~]# sqlite3 【数据库名】 < backup.sql 三.sql 命令 1)创建一个表 create table stu(id Integer,name char ,scroe Integer); 常见一个表格 ,表名 ,字段, 字段名, 字段类型,以分号结尾; 不以点开头,以分号结尾 2)插入一条数据 insert into stu values(Id Insteger, name char, score Integer); isnert into stu (name, scroe)values(1003,"wangwu"); 3)查询 select *from stu // 查询所有字段 select name from stu // 查询部分字段 select score from stu 4)按照条件查询 select * from stu where score=80; select *from stu where scroe =90 and id =1001; select * from stu where score =90 or name = 'dyy' 5)删除一条数据 delete from stu where id =1003; delete from stu where name = 'dyy'; delete from stu where name = 'dyy' and score = 90; delete from stu where name = 'dyy' or scroe = 100; 6)更新一条数据 update stu set name = 'wangwu' where id =1001; update stu set name= 'wangwu',score = 90 where id =1001 ps: SQLite3对于数据的类型检查是是比较弱的,在操作数据库的时候

最后

以上就是刻苦唇膏最近收集整理的关于Android Sqlite3基本命令Sqlite3命令的全部内容,更多相关Android内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(76)

评论列表共有 0 条评论

立即
投稿
返回
顶部