加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

SQLite初体验

发布时间:2020-12-12 19:35:23 所属栏目:百科 来源:网络整理
导读:1 摘要 SQLite is a software library that implements a self-contained,serverless,zero-configuration,transactional SQL database engine. SQLite is the most widely deployed database engine in the world. The source code for SQLite is in the pub

1 摘要

SQLite is a software library that implements a self-contained,serverless,zero-configuration,transactional SQL database engine. SQLite is the most widely deployed database engine in the world. The source code for SQLite is in the public domain. More…

SQLite是一款数据库引擎软件,它不依赖任何软件或平台,无需开启服务,零配置且支持事务处理。SQLite是世界上部署最广泛的数据库引擎。其源代码是完全公开的。更多

2 安装

2.1 下载

首先从官网http://www.sqlite.org/download.html下载SQLite软件安装包,如下图(以Windows为例)。下载两个文件,一是图中“Precompiled Binaries for Windows”下对应位数的压缩包,如“sqlite-dll-win64-x64-3090200.zip”;一是shell压缩包,如“sqlite-shell-win32-x86-3090200.zip”。

2.2 解压

下载后解压这两个压缩包得到三个文件“sqlite3.def”、“sqlite3.dll”和“sqlite3.exe”。将这三个文件放到C盘同一目录下,如下图所示。

2.3 配置环境变量

找到刚才放置的目录,即“sqlite.exe”所在目录。复制该路径,并将该路径添加到系统环境变量path中,如“C:Program Files (x86)sqlite;”添加到下图中的path中。

2.4 查看配置是否成功

win + R 打开命令行CMD,输入sqlite3回车出现如下图中提示则表示安装成功。

3 小试牛刀

3.1 新建数据库

在当前目录下新建一个名为“User.db”的文件,并打开该数据库文件。

sqlite>.open User.db

查看当前已经打开的数据库文件。

sqlite>.databases

3.2 新建数据表

创建名为user的数据表,含有两个字段idname

sqlite>create table user(id integer primary key,name text);

查看当前所有数据表

sqlite>.tables

user表中插入两条数据

sqlite>insert into user(id,name) values(1,'Jack');
sqlite>insert into user(id,name) values(2,'Tim');

查看user表中数据

sqlite>select * from user;

3.3 常用设置

显示当前设置

sqlite>.show

设置数据表显示格式为column

sqlite>.mode column

设置数据表显示表头

sqlite>.headers ON

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读