SQLite安装与使用图文详解

148 阅读2分钟

推荐框架

基于SpringBoot3+Vue3前后端分离的Java快速开发框架

项目简介:基于 JDK 17、Spring Boot 3、Spring Security 6、JWT、Redis、Mybatis-Plus、Knife4j等构建后端,基于Vue 3、Element-Plus 、TypeScript等构建前端的分离单体权限管理系统。

项目地址:

后端:

gitee: gitee.com/harry-tech/…

gitcode: gitcode.com/harry-tech/…

前端:

gitee: gitee.com/harry-tech/…

gitcode.com/harry-tech/…

觉着有帮助,给个Star再走呗
公众号搜“Harry技术”,关注我,带你看不一样的人间烟火!

SQLite安装与使用图文详解

什么是 SQLite?

SQLite是一个进程内的库,实现了自给自足的、无服务器的、零配置的、事务性的 SQL 数据库引擎。它是一个零配置的数据库,这意味着与其他数据库不一样,您不需要在系统中配置。

就像其他数据库,SQLite 引擎不是一个独立的进程,可以按应用程序需求进行静态或动态连接。SQLite 直接访问其存储文件。

在 Windows 上安装 SQLite

请访问 SQLite 下载页面,从 Windows 区下载预编译的二进制文件。

您需要下载 sqlite-tools-win32-*.zipsqlite-dll-win32-*.zip 压缩文件。

image-20250107105036475

创建文件夹 D:\sqlite,并在此文件夹下解压上面两个压缩文件,将得到 sqlite3.def、sqlite3.dll 和 sqlite3.exe 文件。

image-20250107105400396

添加 D:\sqlite 到 PATH 环境变量,最后在命令提示符下,使用 sqlite3 命令,将显示如下结果。

image-20250107105526561

image-20250107105616213

Navicat连接

image-20250107110021380

image-20250107105754104

image-20250107105836910

常用命令

1、查找帮助命令                                    .help
2、退出SQLite命令                                .q  .quit   .exit
3、显示各种设置的当前值                    .show
4、查看表的create模式                      .schema     .schema name
5、显示当前打开的数据库文件          .database
6、显示数据库中所有的表名               .tables
7、创建或者打开一个数据库               sqlite3 xxx.db
1、创建新表
create table 表名(id integer ,name text,passwd integer);-->未指定类型默认字符串,字符串添加新纪录时用""
​
2、删除表
drop table 表名
​
3、查询表中记录
select * from 表名    ------> 所有记录
select * from 表名 where id<2;
​
5、向表中添加新纪录
insert into 表名 values(1,"zhangsan",123);
insert into 表名(id ,name ,passwd) values(1,"zhangsan",123);
​
6、按指定条件删除表中的记录
delete from 表名 where id=1;
​
7、更新表中记录
update 表名 set name="xiaoming",passwd=555 where id=1;
​
8、在表中添加字段(列)
alter table 表名 add column age integer;