当前位置:网站首页>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,在操作数据库的时候
边栏推荐
猜你喜欢

技术分享| 融合调度系统中的电子围栏功能说明

Button control switch 4017 digital circuit chip

【北亚数据恢复】IBM System Storage存储lvm信息丢失数据恢复方案

节省50%成本!京东云重磅发布新一代混合CDN产品

State security organs conduct criminal arrest and summons review on Yang Zhiyuan, a suspect suspected of endangering national security

Technology sharing | Description of the electronic fence function in the integrated dispatching system

中大型商业银行堡垒机升级改造就用行云管家!必看!

Qt的QItemDelegate使用

Lixia Action | Kyushu Yunzhang Jinnan: Open source is not a movement for a few people, popularization is the source

【剑指offer59】队列的最大值
随机推荐
Analysis and application of portrait segmentation technology
F.金玉其外矩阵(构造)
【问题解决】QT更新组件出现 “要继续此操作,至少需要一个有效且已启用的储存库”
如何在ubuntu环境下安装postgresql并配置远程访问
Phasecraft连下两城,助力英国量子技术商业化加速!
文盘Rust -- 配置文件解析
本周讨论用户体验:Daedalus 的 Nemo 加入 Ambire,探索加密海洋
Theory 1: Deep Learning - Detailed Explanation of the LetNet Model
《中国综合算力指数》《中国算力白皮书》《中国存力白皮书》《中国运力白皮书》在首届算力大会上重磅发出
如何和程序员谈恋爱
metaRTC5.0新版本支持mbedtls(PolarSSL)
SLAM 04.视觉里程计-1-相机模型
How to Identify Asynchronous I/O Bottlenecks
用于X射线聚焦的复合折射透镜
Centos7 install mysql version rapidly
阿里老鸟终于把测试用例怎么写说的明明白白了,小鸟必看
【硬件架构的艺术】学习笔记(1)亚稳态的世界
【剑指offer33】二叉搜索树的后序遍历序列
Redis 复习计划 - Redis主从数据一致性和哨兵机制
zabbix自定义图形