SQLite导出数据库至sql文件

news/2024/10/22 12:22:15/

SQLite是一款实现了自包含、无服务器、零配置、事务性SQL数据库引擎的软件库。SQLite是世界上部署最广泛的SQL数据库引擎。
SQLite 是非常小的,是轻量级的,完全配置时小于 400KiB,省略可选功能配置时小于250KiB。
SQLite 源代码不受版权限制。

Dbeaver等工具支持数据表导出为sql文件,但无法直接将数据库导出至整个sql文件中

1.软件包下载
  • 这里在Windows 10操作系统下配置,下载x64包。tools、ddl工具包下载,下载主页地址为:https://www.sqlite.org/download.html
    • sqlite-dll-win-x64-3450300.zip
    • sqlite-tools-win-x64-3450300.zip
      在这里插入图片描述
2.文件解压合并
  • 把下载的两个安装包解压到新建目录下,路径目录下最终共有五个文件,如下图所示:
    在这里插入图片描述
3.SQLite命令导出数据库至sql文件
  • 命令行及执行效果
.\sqlite-\sqlite3.exe db.healthclub .dump > ..\YouliTest\HeaClub.sql

在这里插入图片描述

4.SQLite其他命令
.exit	退出 sqlite 提示符。
.header(s) on|off	开启或关闭头部显示。
.help	显示消息。
.mode mode	设置输出模式,mode 可以是下列之一:csv 逗号分隔的值column 左对齐的列html html 的 <table> 代码insert table 表的 sql 插入(insert)语句line 每行一个值list 由 .separator 字符串分隔的值tabs 由 tab 分隔的值tcl tcl 列表元素
.nullvalue string	在 null 值的地方输出 string 字符串。
.quit	退出 sqlite 提示符。
.schema ?table?	显示 create 语句。如果指定了 table 表,则只显示匹配 like 模式的 table 表。
.separator string	改变输出模式和 .import 所使用的分隔符。
.show	显示各种设置的当前值。
.stats on|off	开启或关闭统计。
.tables ?pattern?	列出匹配 like 模式的表的名称。
.width num num	为 "column" 模式设置列宽度。
.timer on|off	开启或关闭 cpu 定时器。
  • 演示效果
D:\..\HealthClub>D:\..\sqlite-\sqlite3.exe db.healthclub
SQLite version 3.45.3 2024-04-15 13:34:05 (UTF-16 console I/O)
Enter ".help" for usage hints.
sqlite>
sqlite>
sqlite> .databases
main: D:\..\HealthClub\db.healthclub r/w
sqlite> .schema bbs_post
CREATE TABLE IF NOT EXISTS "bbs_post" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "title" varchar(20) NOT NULL, "content" text NOT NULL, "comment_num" integer NOT NULL, "read_num" integer NOT NULL, "is_essence" bool NOT NULL, "add_time" datetime NOT NULL, "author_id" integer NOT NULL REFERENCES "users_usermessage" ("id") DEFERRABLE INITIALLY DEFERRED, "board_id" integer NOT NULL REFERENCES "bbs_board" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE INDEX "bbs_post_author_id_04bf457a" ON "bbs_post" ("author_id");
CREATE INDEX "bbs_post_board_id_85a114b6" ON "bbs_post" ("board_id");
sqlite> .header on
sqlite> .mode column
sqlite> .timer on
sqlite> .schema bbs_post
CREATE TABLE IF NOT EXISTS "bbs_post" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "title" varchar(20) NOT NULL, "content" text NOT NULL, "comment_num" integer NOT NULL, "read_num" integer NOT NULL, "is_essence" bool NOT NULL, "add_time" datetime NOT NULL, "author_id" integer NOT NULL REFERENCES "users_usermessage" ("id") DEFERRABLE INITIALLY DEFERRED, "board_id" integer NOT NULL REFERENCES "bbs_board" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE INDEX "bbs_post_author_id_04bf457a" ON "bbs_post" ("author_id");
CREATE INDEX "bbs_post_board_id_85a114b6" ON "bbs_post" ("board_id");
sqlite> .showecho: offeqp: offexplain: autoheaders: onmode: column --wrap 60 --wordwrap off --noquotenullvalue: ""output: stdout
colseparator: "|"
rowseparator: "\n"stats: offwidth:filename: db.healthclub
sqlite> .separator row '\n'
sqlite> .nullvalue NULL
sqlite> .schema bbs_post
CREATE TABLE IF NOT EXISTS "bbs_post" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "title" varchar(20) NOT NULL, "content" text NOT NULL, "comment_num" integer NOT NULL, "read_num" integer NOT NULL, "is_essence" bool NOT NULL, "add_time" datetime NOT NULL, "author_id" integer NOT NULL REFERENCES "users_usermessage" ("id") DEFERRABLE INITIALLY DEFERRED, "board_id" integer NOT NULL REFERENCES "bbs_board" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE INDEX "bbs_post_author_id_04bf457a" ON "bbs_post" ("author_id");
CREATE INDEX "bbs_post_board_id_85a114b6" ON "bbs_post" ("board_id");
sqlite> .mode column;.headers on;.separator ROW "\n";.nullvalue NULL;select * from bbs_post
extra argument: "ROW"
sqlite> select * from bbs_post...> ;
id  title        content                     comment_num  read_num  is_essence  add_time                    author_id  board_id
--  -----------  --------------------------  -----------  --------  ----------  --------------------------  ---------  --------
2   我想减肥         <p>有没有朋友一起减肥呢?</p>          2            7         0           2020-07-25 13:20:49.728140  6          1
3   希望我减肥成功      <p>已经买了课程了,希望我可以瘦身20~</p>  1            3         0           2020-07-28 20:14:18.626428  6          1
4   我开了减肥课程      <p>欢迎同学们来报名学习!</p>          0            2         0           2020-07-28 20:32:33.640089  4          1
5   111          <p>222</p>                  1            4         0           2020-07-29 00:13:16.005981  4          1
6   21232312345  <p>21232312345</p>          0            1         0           2024-04-20 22:26:08.160594  6          1
Run Time: real 0.006 user 0.000000 sys 0.000000
sqlite> select * from bbs_post;
id  title        content                     comment_num  read_num  is_essence  add_time                    author_id  board_id
--  -----------  --------------------------  -----------  --------  ----------  --------------------------  ---------  --------
2   我想减肥         <p>有没有朋友一起减肥呢?</p>          2            7         0           2020-07-25 13:20:49.728140  6          1
3   希望我减肥成功      <p>已经买了课程了,希望我可以瘦身20~</p>  1            3         0           2020-07-28 20:14:18.626428  6          1
4   我开了减肥课程      <p>欢迎同学们来报名学习!</p>          0            2         0           2020-07-28 20:32:33.640089  4          1
5   111          <p>222</p>                  1            4         0           2020-07-29 00:13:16.005981  4          1
6   21232312345  <p>21232312345</p>          0            1         0           2024-04-20 22:26:08.160594  6          1
Run Time: real 0.006 user 0.000000 sys 0.000000
sqlite> analyze bbs_post;
Run Time: real 0.011 user 0.000000 sys 0.000000
sqlite> .table
auth_group                          django_content_type
auth_group_permissions              django_migrations
auth_permission                     django_session
bbs_board                           reversion_revision
bbs_comment                         reversion_version
bbs_notify                          teachers_teacher
bbs_post                            users_banner
course_course                       users_userfavorite
course_courselist                   users_usermember
course_ctype                        users_usermessage
course_lesson                       users_usermessage_groups
course_video                        users_usermessage_user_permissions
django_admin_log                    users_usersign
sqlite> .header off
sqlite> select * from bbs_post;
2   我想减肥         <p>有没有朋友一起减肥呢?</p>          2            7         0           2020-07-25 13:20:49.728140  6          1
3   希望我减肥成功      <p>已经买了课程了,希望我可以瘦身20~</p>  1            3         0           2020-07-28 20:14:18.626428  6          1
4   我开了减肥课程      <p>欢迎同学们来报名学习!</p>          0            2         0           2020-07-28 20:32:33.640089  4          1
5   111          <p>222</p>                  1            4         0           2020-07-29 00:13:16.005981  4          1
6   21232312345  <p>21232312345</p>          0            1         0           2024-04-20 22:26:08.160594  6          1
Run Time: real 0.002 user 0.000000 sys 0.000000
sqlite> .showecho: offeqp: offexplain: autoheaders: offmode: column --wrap 60 --wordwrap off --noquotenullvalue: "NULL"output: stdout
colseparator: "row"
rowseparator: "\\n"stats: offwidth: 0 0 0 0 0 0 0 0 0filename: db.healthclub
sqlite> .mode tcl
sqlite> select * from bbs_post;
"2" "我想减肥" "<p>有没有朋友一起减肥呢?</p>" "2" "7" "0" "2020-07-25 13:20:49.728140" "6" "1"
"3" "希望我减肥成功" "<p>已经买了课程了,希望我可以瘦身20斤~</p>" "1" "3" "0" "2020-07-28 20:14:18.626428" "6" "1"
"4" "我开了减肥课程" "<p>欢迎同学们来报名学习!</p>" "0" "2" "0" "2020-07-28 20:32:33.640089" "4" "1"
"5" "111" "<p>222</p>" "1" "4" "0" "2020-07-29 00:13:16.005981" "4" "1"
"6" "21232312345" "<p>21232312345</p>" "0" "1" "0" "2024-04-20 22:26:08.160594" "6" "1"
Run Time: real 0.007 user 0.000000 sys 0.000000
sqlite> .mode column
sqlite> select * from bbs_post;
2   我想减肥         <p>有没有朋友一起减肥呢?</p>          2            7         0           2020-07-25 13:20:49.728140  6          1
3   希望我减肥成功      <p>已经买了课程了,希望我可以瘦身20~</p>  1            3         0           2020-07-28 20:14:18.626428  6          1
4   我开了减肥课程      <p>欢迎同学们来报名学习!</p>          0            2         0           2020-07-28 20:32:33.640089  4          1
5   111          <p>222</p>                  1            4         0           2020-07-29 00:13:16.005981  4          1
6   21232312345  <p>21232312345</p>          0            1         0           2024-04-20 22:26:08.160594  6          1
Run Time: real 0.007 user 0.000000 sys 0.000000
sqlite> .header on
sqlite> select * from bbs_post;
id  title        content                     comment_num  read_num  is_essence  add_time                    author_id  board_id
--  -----------  --------------------------  -----------  --------  ----------  --------------------------  ---------  --------
2   我想减肥         <p>有没有朋友一起减肥呢?</p>          2            7         0           2020-07-25 13:20:49.728140  6          1
3   希望我减肥成功      <p>已经买了课程了,希望我可以瘦身20~</p>  1            3         0           2020-07-28 20:14:18.626428  6          1
4   我开了减肥课程      <p>欢迎同学们来报名学习!</p>          0            2         0           2020-07-28 20:32:33.640089  4          1
5   111          <p>222</p>                  1            4         0           2020-07-29 00:13:16.005981  4          1
6   21232312345  <p>21232312345</p>          0            1         0           2024-04-20 22:26:08.160594  6          1
Run Time: real 0.006 user 0.000000 sys 0.000000
sqlite> .showecho: offeqp: offexplain: autoheaders: onmode: column --wrap 60 --wordwrap off --noquotenullvalue: "NULL"output: stdout
colseparator: " "
rowseparator: "\n"stats: offwidth: 0 0 0 0 0 0 0 0 0filename: db.healthclub
sqlite> .stats on
sqlite> select * from bbs_post;
id  title        content                     comment_num  read_num  is_essence  add_time                    author_id  board_id
--  -----------  --------------------------  -----------  --------  ----------  --------------------------  ---------  --------
2   我想减肥         <p>有没有朋友一起减肥呢?</p>          2            7         0           2020-07-25 13:20:49.728140  6          1
3   希望我减肥成功      <p>已经买了课程了,希望我可以瘦身20~</p>  1            3         0           2020-07-28 20:14:18.626428  6          1
4   我开了减肥课程      <p>欢迎同学们来报名学习!</p>          0            2         0           2020-07-28 20:32:33.640089  4          1
5   111          <p>222</p>                  1            4         0           2020-07-29 00:13:16.005981  4          1
6   21232312345  <p>21232312345</p>          0            1         0           2024-04-20 22:26:08.160594  6          1
Memory Used:                         255016 (max 268976) bytes
Number of Outstanding Allocations:   773 (max 838)
Number of Pcache Overflow Bytes:     8200 (max 12296) bytes
Largest Allocation:                  87360 bytes
Largest Pcache Allocation:           4104 bytes
Lookaside Slots Used:                104 (max 123)
Successful lookaside attempts:       2436
Lookaside failures due to size:      116
Lookaside failures due to OOM:       1066
Pager Heap Usage:                    44112 bytes
Page cache hits:                     58
Page cache misses:                   8
Page cache writes:                   3
Page cache spills:                   0
Schema Heap Usage:                   22576 bytes
Statement Heap/Lookaside Usage:      21640 bytes
Fullscan Steps:                      4
Sort Operations:                     0
Autoindex Inserts:                   0
Virtual Machine Steps:               61
Reprepare operations:                0
Number of times run:                 1
Memory used by prepared stmt:        21640
Run Time: real 0.013 user 0.000000 sys 0.000000
sqlite> .width 6
sqlite> select * from bbs_post;
id      title        content                     comment_num  read_num  is_essence  add_time                    author_id  board_id
------  -----------  --------------------------  -----------  --------  ----------  --------------------------  ---------  --------
2       我想减肥         <p>有没有朋友一起减肥呢?</p>          2            7         0           2020-07-25 13:20:49.728140  6          1
3       希望我减肥成功      <p>已经买了课程了,希望我可以瘦身20~</p>  1            3         0           2020-07-28 20:14:18.626428  6          1
4       我开了减肥课程      <p>欢迎同学们来报名学习!</p>          0            2         0           2020-07-28 20:32:33.640089  4          1
5       111          <p>222</p>                  1            4         0           2020-07-29 00:13:16.005981  4          1
6       21232312345  <p>21232312345</p>          0            1         0           2024-04-20 22:26:08.160594  6          1
Memory Used:                         255016 (max 268976) bytes
Number of Outstanding Allocations:   773 (max 838)
Number of Pcache Overflow Bytes:     8200 (max 12296) bytes
Largest Allocation:                  87360 bytes
Largest Pcache Allocation:           4104 bytes
Lookaside Slots Used:                104 (max 123)
Successful lookaside attempts:       2506
Lookaside failures due to size:      117
Lookaside failures due to OOM:       1086
Pager Heap Usage:                    44112 bytes
Page cache hits:                     2
Page cache misses:                   0
Page cache writes:                   0
Page cache spills:                   0
Schema Heap Usage:                   22576 bytes
Statement Heap/Lookaside Usage:      21640 bytes
Fullscan Steps:                      4
Sort Operations:                     0
Autoindex Inserts:                   0
Virtual Machine Steps:               61
Reprepare operations:                0
Number of times run:                 1
Memory used by prepared stmt:        21640
Run Time: real 0.010 user 0.000000 sys 0.000000
sqlite>

http://www.ppmy.cn/news/1442464.html

相关文章

Node.js使用

Node.js是一个基于Chrome V8引擎的JavaScript运行环境&#xff0c;它使得JavaScript能够脱离浏览器&#xff0c;直接在服务器端运行。Node.js的异步I/O模型使其在处理高并发请求时表现出色&#xff0c;适用于构建网络应用、实时应用等。以下是对Node.js使用的总结&#xff1a; …

C++初识内存管理和模版

目录 前言 1.C/C内存分布 2. C的内存管理方式 2.1 new/delete操作内置类型 2. new和delete操作自定义类型 3. operator new和operator delete函数 4. new和delete的实现原理 4.1 内置类型 4.2 自定义类型 5. malloc/free和new/delete的区别 6. 初识模版 6.1 泛型编…

Spring从零开始学使用系列(三)--依赖注入(DI)

目录 1.DI的核心概念 1.1优势 2. Spring中的DI实现 2.1 构造器注入 2.1.2 优势和缺点 2.2 设置器注入 2.2.1 如何使用设置器注入 2.2.2 示例代码 2.2.3优势和使用场景 2.3 字段注入 2.4 方法注入 2.4.1 方法注入的概念 2.4.2 找方法注入 2.4.3 Lookup 注解的作用 2…

贪心算法练习day.5

435.无重叠区间 链接&#xff1a;. - 力扣&#xff08;LeetCode&#xff09; 题目描述&#xff1a; 给定一个区间的集合 intervals &#xff0c;其中 intervals[i] [starti, endi] 。返回 需要移除区间的最小数量&#xff0c;使剩余区间互不重叠 。 示例 1: 输入: intervals…

对于AIGC(人工智能)我们应该如何看待

文章目录 前言一、AIGC技术的现状与特点二、AIGC技术在各个领域的应用三、AIGC技术对未来社会的影响四、AIGC技术的可能发展方向 前言 随着科技的飞速发展&#xff0c;人工智能与大数据的结合日益紧密&#xff0c;AIGC&#xff08;人工智能生成内容&#xff09;技术作为这一领域…

免费开源圈子社交交友社区系统 可打包小程序 支持二开 源码交付!

线上社交的好处&#xff1a; 当今社会&#xff0c;人们越来越依赖于网络社交。互联网无疑为人类带来了许多好处&#xff0c; 其中一个就是线上社交。通过各种社交平台&#xff0c;人们可以随时随地互动交流&#xff0c;扩大自 己的社交圈&#xff0c;丰富生活。但是&#xf…

Flutter 复杂列表开发与性能优化全攻略(现在看为时不晚!)

​ 一、Flutter 中常见的复杂列表样式及应用场景 在移动应用开发中,列表可以说是最常见、最重要的 UI 组件之一。它不仅能够高效地展示大量数据,还能提供丰富的交互方式,让用户能够快速浏览和查找所需信息。而在实际开发中,我们经常会遇到各种复杂的列表需求,这就对我们的开发…

Office疑难杂症-Word页码重复无法修改

在现代办公环境中&#xff0c;Microsoft Office 套件扮演着不可或缺的角色&#xff0c;尤其是 Word 文档处理软件&#xff0c;在日常生活和工作中的应用广泛。然而&#xff0c;即使是这样成熟的软件&#xff0c;也不免有一些令人头疼的技术问题。本文将详细介绍如何解决Word中页…