当前位置:网站首页>Android Sqlite3 basic commands
Android Sqlite3 basic commands
2022-08-04 14:31:00 【Just_Paranoid】
Sqlite3命令
一、基本操作命令:(系统命令)
1、创建数据库:
sqlite3 数据库名
例如:[[email protected] ~]# 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、Get a list of indexes for the specified table:
sqlite> .indices 【表名】
7、从SQL文件导入数据库:
sqlite> .read 【文件名】
8、导出数据库到SQL文件:
sqlite> .output 【文件名】
sqlite> .dump
sqlite> .output stdout
9、Format the output data toCSV格式:
sqlite> .output 【文件名.csv】
sqlite> .separator
sqlite> .select * from test;
sqlite> .output stdout
10、从CSVfile to import data into a table:
sqlite> .import 【文件名.csv】 【表名】
附录:
.help 查看帮助说明
.dbinfo 查看数据库信息
11、备份数据库:
[[email protected] ~]# sqlite3 【数据库名】 .dump > backup.sql
12、恢复数据库:
[[email protected]~]# sqlite3 【数据库名】 < backup.sql
三.sql 命令
1)创建一个表
create table stu(id Integer,name char ,scroe Integer);
A common form ,表名 ,字段, 字段名, 字段类型,以分号结尾;
does not start with a dot,以分号结尾
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: SQLite3Type checking for data is relatively weak,在操作数据库的时候
边栏推荐
- 代码随想录笔记_动态规划_1049最后一块石头的重量II
- 一看就会的Chromedriver(谷歌浏览器驱动)安装教程
- Technology sharing | Mini program realizes audio and video calls
- 【剑指offer33】二叉搜索树的后序遍历序列
- 第六届未来网络发展大会,即将开幕!
- Qt的QItemDelegate使用
- SLAM 04.视觉里程计-1-相机模型
- "C pitfalls and pitfalls" reading summary
- G.登山小分队(暴力&dfs)
- How to automatically renew the token after it expires?
猜你喜欢
随机推荐
利用决策树找出最优特征组合
如何在ubuntu环境下安装postgresql并配置远程访问
【硬件架构的艺术】学习笔记(1)亚稳态的世界
JCMsuite应用:倾斜平面波传播透过光阑的传输
Almost all known protein structures in the world are open sourced by DeepMind
AOSP内置APP特许权限白名单
第六届未来网络发展大会,即将开幕!
一看就会的Chromedriver(谷歌浏览器驱动)安装教程
MySQL【触发器】
token 过期后,如何自动续期?
word2003按空格键为什么会出现小数点
关于redis的几件小事(五)redis保证高并发以及高可用
【Web技术】1401- 图解 Canvas 入门
Crawler - basic use of selenium, no interface browser, other uses of selenium, cookies of selenium, crawler cases
MySQL【窗口函数】【共用表表达式】
X射线掠入射聚焦反射镜
开发者独立搭建一个跨模态搜索应用有多难?
[Problem solving] QT update component appears "To continue this operation, at least one valid and enabled repository is required"
解题-->在线OJ(十八)
CF1527D MEX Tree (mex & tree & inclusive)