• 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
    
    • 1

    在这里插入图片描述

    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 定时器。
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 演示效果
    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" "我想减肥" "

    有没有朋友一起减肥呢?

    "
    "2" "7" "0" "2020-07-25 13:20:49.728140" "6" "1" "3" "希望我减肥成功" "

    已经买了课程了,希望我可以瘦身20斤~

    "
    "1" "3" "0" "2020-07-28 20:14:18.626428" "6" "1" "4" "我开了减肥课程" "

    欢迎同学们来报名学习!

    "
    "0" "2" "0" "2020-07-28 20:32:33.640089" "4" "1" "5" "111" "

    222

    "
    "1" "4" "0" "2020-07-29 00:13:16.005981" "4" "1" "6" "21232312345" "

    21232312345

    "
    "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
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193
    • 194
    • 195
    • 196
    • 197
    • 198
    • 199
    • 200
    • 201
  • 相关阅读:
    Java中CAS算法的集中体现:Atomic原子类库,你了解吗?
    MySQL基础与库的基本操作
    数据结构中树、森林 与 二叉树的转换
    [精选] 多账号统一登录,你如何设计?
    复盘:基于attention的多任务多模态实情绪情感识别,基于BERT实现文本情感分类(pytorch实战)
    阿里云服务器续费流程_一篇文章搞定
    挂载VMware esxi服务器文件夹到本地ubuntu
    设备树和uboot启动,kernel启动
    Redis-shake 数据迁移工具
    集美大学 - 2840 - 实验2-1
  • 原文地址:https://blog.csdn.net/qq_24452475/article/details/138046921