当前位置:网站首页>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,在操作数据库的时候
边栏推荐
猜你喜欢
随机推荐
Win11勒索软件防护怎么打开?Win11安全中心勒索软件防护如何设置
Kyushu Cloud attended the Navigator Online Forum to discuss the current status, challenges and future of 5G MEC edge computing
Almost all known protein structures in the world are open sourced by DeepMind
xpath获取带命名空间节点注意事项
关于redis的几件小事(五)redis保证高并发以及高可用
AlphaFold 如何实现 AI 在结构生物学中的全部潜力
广告电商系统开发功能只订单处理
word2003按空格键为什么会出现小数点
Unity插件:使用PopulationSystem制作行走交流的路人
如何在ubuntu环境下安装postgresql并配置远程访问
License server system does not support this version of this feature
ssm learning experience (final chapter)
并发程序的隐藏杀手——假共享(False Sharing)
ICML 2022 | 图神经网络的局部增强
SQL语句的写法:Update、Case、 Select 一起的用法
理论篇1:深度学习之----LetNet模型详解
[Problem solving] QT update component appears "To continue this operation, at least one valid and enabled repository is required"
编译型与解释型编程语言的区别
异步编程概览
考研上岸又转行软件测试,从5k到13k完美逆袭,杭州校区小哥哥拒绝平庸终圆梦!









