当前位置:网站首页>Android Sqlite3基本命令
Android Sqlite3基本命令
2022-08-04 14:28: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、获取指定表的索引列表:
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、备份数据库:
[[email protected] ~]# sqlite3 【数据库名】 .dump > backup.sql
12、恢复数据库:
[[email protected]~]# 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对于数据的类型检查是是比较弱的,在操作数据库的时候
边栏推荐
- 编程思想_编程有必要给孩子学吗?
- 按键控制开关4017芯片数字电路
- CCF GLCC officially opened | Kyushu Cloud open source experts bring generous bonuses to help universities promote open source
- 手搓一个“七夕限定”,用3D Engine 5分钟实现烟花绽放效果
- 属于程序猿的浪漫
- 快解析结合友加畅捷U+
- 九州云出席领航者线上论坛,共话5G MEC边缘计算现状、挑战和未来
- 解题-->在线OJ(十八)
- ICML 2022 | 图神经网络的局部增强
- 第十六章 源代码文件 REST API 教程(一)
猜你喜欢
[The Art of Hardware Architecture] Study Notes (1) The World of Metastability
Redis 复习计划 - Redis主从数据一致性和哨兵机制
从理论到实践:MySQL性能优化和高可用架构,一次讲清
idea永久激活教程(新版)
Fuse bit of AVR study notes
"C pitfalls and pitfalls" reading summary
实际工作中的高级技术(训练加速、推理加速、深度学习自适应、对抗神经网络)
Win11快速助手在哪里?Win11打开快速助手的方法
特殊品种的二次开户验资金额
物联网应用发展趋势
随机推荐
Lecture 4 SVN
B. Construct a simple sequence (greedy)
世间几乎所有已知蛋白质结构,都被DeepMind开源了
CF1527D MEX Tree(mex&树&容斥)
节省50%成本!京东云重磅发布新一代混合CDN产品
如何在ubuntu环境下安装postgresql并配置远程访问
相似文本聚类与调参
G.登山小分队(暴力&dfs)
阿里老鸟终于把测试用例怎么写说的明明白白了,小鸟必看
化算力为战力:宁夏中卫的数字化转型启示录
文盘Rust -- 配置文件解析
异步编程概览
用了TCP协议,就一定不会丢包吗?
ssm learning experience (final chapter)
xampp安装包含的组件有(php,perl,apche,mysql)
idea removes spark logs
Win11勒索软件防护怎么打开?Win11安全中心勒索软件防护如何设置
How to automatically renew the token after it expires?
【剑指offer33】二叉搜索树的后序遍历序列
第十六章 源代码文件 REST API 教程(一)