SQLite导出数据库至sql文件

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

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

1.软件包下载
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> .show
        echo: off
         eqp: off
     explain: auto
     headers: on
        mode: column --wrap 60 --wordwrap off --noquote
   nullvalue: ""
      output: stdout
colseparator: "|"
rowseparator: "\n"
       stats: off
       width:
    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> .show
        echo: off
         eqp: off
     explain: auto
     headers: off
        mode: column --wrap 60 --wordwrap off --noquote
   nullvalue: "NULL"
      output: stdout
colseparator: "row"
rowseparator: "\\n"
       stats: off
       width: 0 0 0 0 0 0 0 0 0
    filename: 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> .show
        echo: off
         eqp: off
     explain: auto
     headers: on
        mode: column --wrap 60 --wordwrap off --noquote
   nullvalue: "NULL"
      output: stdout
colseparator: " "
rowseparator: "\n"
       stats: off
       width: 0 0 0 0 0 0 0 0 0
    filename: 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>

相关推荐

  1. c# sqlite导出导入数据表 作为sql文件

    2024-04-22 06:12:08       22 阅读
  2. 创建数据库sqlite3文件

    2024-04-22 06:12:08       12 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-04-22 06:12:08       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-22 06:12:08       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-22 06:12:08       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-22 06:12:08       20 阅读

热门阅读

  1. yarn的安装与配置(Windows/macOS)

    2024-04-22 06:12:08       12 阅读
  2. 记录mac上图像处理

    2024-04-22 06:12:08       13 阅读
  3. 面:go能不能手写一个简单的协程池?

    2024-04-22 06:12:08       11 阅读
  4. 【LeetCode热题100】【动态规划】零钱兑换

    2024-04-22 06:12:08       13 阅读
  5. 力扣练习题(2024/4/17)

    2024-04-22 06:12:08       13 阅读
  6. 实现动态组件的方式

    2024-04-22 06:12:08       11 阅读
  7. linux环境下创建网口聚合实例

    2024-04-22 06:12:08       14 阅读
  8. 子组件向父组件传参的方式?

    2024-04-22 06:12:08       19 阅读
  9. MySQL数据库——11、MySQL LIKE 子句

    2024-04-22 06:12:08       14 阅读
  10. [面向对象程序设计]包含警戒

    2024-04-22 06:12:08       24 阅读