当前位置:网站首页>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对于数据的类型检查是是比较弱的,在操作数据库的时候
边栏推荐
猜你喜欢

国家安全机关对涉嫌危害国家安全犯罪嫌疑人杨智渊实施刑事拘传审查

【历史上的今天】8 月 4 日:第一位图灵奖女性得主;NVIDIA 收购 MediaQ;首届网络安全挑战大赛完成

考研上岸又转行软件测试,从5k到13k完美逆袭,杭州校区小哥哥拒绝平庸终圆梦!

CCF GLCC正式开营|九州云开源专家携丰厚奖金,助力高校开源推广

How to automatically renew the token after it expires?

广告电商系统开发功能只订单处理

【 HMS core 】 【 Media 】 online video editing service 】 【 material can't show, or network anomalies have been Loading state
MySQL性能指标TPS\QPS\IOPS如何压测?

The Internet of things application development trend

相似文本聚类与调参
随机推荐
Problem solving-->Online OJ (18)
SLAM 04.视觉里程计-1-相机模型
两款移相振荡器的对比
异步编程概览
属于程序猿的浪漫
理论篇1:深度学习之----LetNet模型详解
国家安全机关对涉嫌危害国家安全犯罪嫌疑人杨智渊实施刑事拘传审查
【剑指offer59】队列的最大值
Theory 1: Deep Learning - Detailed Explanation of the LetNet Model
leetcode 48. Rotate Image 旋转图像(Medium)
CCF GLCC正式开营|九州云开源专家携丰厚奖金,助力高校开源推广
idea永久激活教程(新版)
兆骑科创创新创业大赛活动举办,线上直播路演,投融资对接
AlphaFold 如何实现 AI 在结构生物学中的全部潜力
Win11快速助手在哪里?Win11打开快速助手的方法
如何才能有效、高效阅读?猿辅导建议“因材因时施教”
How to install postgresql and configure remote access in ubuntu environment
编译型与解释型编程语言的区别
[LeetCode] 38. Appearance sequence
在腾讯,我的试用期总结!