1.创建文件.db
sqlite3 xx.db
2.新建表格:create table if not exists 表名(字段名1 数据类型,字段名2 数据类型);
3.约束条件:if not exists
4.表格里添加数据:insert into 表名 values(数据1,数据2);
5.查询数据:
1.select * from 表名 where 条件;//单一条件
2.select * from stu where name="李四" and "id";//多条件查询
3.模糊查询:like 和 %
select * from stu where name like "李%";
4.order by 升序asc;降序desc查询
select *from 表名 order by 字段名 asc;
select *from 表名 order by 字段名 desc;
SELECT *from stu order by id DESC;
6.更新 数据
update 表名 set 字段名=新数据 where 字段名 =旧数据;
UPDATE stu1 set name="张三" where name="老林";
7.删除数据
delete from 表名 where 条件;
DELETE FROM stu1 WHERE id=3;
8.摧毁表
DROP TABLE stu
总结:create 、insert into 、select、order by、update ..set..、delete、drop
二、表达式:
1.SQLite - 数值表达式
SELECT numerical_expression as OPERATION_NAME
例如sqlite> SELECT (15 + 6) AS ADDITION
ADDITION = 21
2.SQLite - 日期表达式
SELECT CURRENT_TIMESTAMP;
三、运算
sqlite3语法
最新推荐文章于 2025-04-17 18:50:06 发布
本文详细介绍了SQLite3数据库的语法,包括创建、查询、更新和删除数据的基本操作,适用于Java后端开发者进行本地数据存储。通过实例解析,帮助理解如何在Java应用中集成并使用SQLite3。

最低0.47元/天 解锁文章
2217

被折叠的 条评论
为什么被折叠?



