SQLite导出数据库至sql文件

这篇具有很好参考价值的文章主要介绍了SQLite导出数据库至sql文件。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

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
      SQLite导出数据库至sql文件,数据库系列,数据库,sqlite,导出数据库至sql文件
2.文件解压合并
  • 把下载的两个安装包解压到新建目录下,路径目录下最终共有五个文件,如下图所示:
    SQLite导出数据库至sql文件,数据库系列,数据库,sqlite,导出数据库至sql文件
3.SQLite命令导出数据库至sql文件
  • 命令行及执行效果
.\sqlite-\sqlite3.exe db.healthclub .dump > ..\YouliTest\HeaClub.sql

SQLite导出数据库至sql文件,数据库系列,数据库,sqlite,导出数据库至sql文件文章来源地址https://www.toymoban.com/news/detail-855834.html

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>

到了这里,关于SQLite导出数据库至sql文件的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 实例讲解C++连接各种数据库,包含SQL Server、MySQL、Oracle、ACCESS、SQLite 和 PostgreSQL、MongoDB 数据库

      C++ 是一种通用的编程语言,可以使用不同的库和驱动程序来连接各种数据库。以下是一些示例代码,演示如何使用 C++ 连接 SQL Server、MySQL、Oracle、ACCESS、SQLite 和 PostgreSQL、MongoDB 数据库。 连接 SQL Server 数据库 要使用 C++ 连接 SQL Server 数据库,可以使用 Microsoft 的 ADODB 库。以

    2024年02月05日
    浏览(49)
  • MS Access 教程之如何将 MDB 文件转换为 SQLite 数据库

    那么如何将 MDB 文件转换为 SQLite 数据库呢?归根结底,最简单的方法是创建一个 MDB 数据库,即半自动转换其他 MDB 文件。我想要一个类似这样的面具: 但在此之前,我必须配置 PC。我从下载 SQLite 开始。我可以使用sqlite.org上的预编译文件快速完成此操作。对于 Windows,我下

    2024年02月05日
    浏览(33)
  • SQLite Studio 连接 SQLite数据库

    1.1、按WIN+R,打开控制台,然后把指引到我们的SQLite的安装路径,输入D:,切换到D盘,cd 地址,切换到具体文件夹,输入“sqlite3”,启动服务 1.2、创建数据库和表  id和name是表的属性(列名),int和varchar是列名的数据类型,int表示是整型,varchar表示是字符串,长度是20,p

    2024年02月15日
    浏览(36)
  • 用idea查看sqlite数据库idea sqlite

                        在此做个笔记

    2024年02月10日
    浏览(37)
  • Python数据库模块(sqlite3,SQLite3)

    创建数据库:在控制台sqlite3 name sqlite3.connect(database [,timeout ,other optional arguments]) 打开数据库;如果指数据库存在则返回一个连接对象,如果不存在则会创建一个数据库; connection.cursor() 创建一个cursor; cursor.execute(sql) 执行一个sql语句,该语句可以被参数化; connection.execut

    2024年03月19日
    浏览(43)
  • 数据库开发(Sqlite)

    1、数据库开发 1.1 数据与数据管理 什么是信息?   信息是指对现实世界存在方式或运动状态的反应。 什么是数据?   数据是指存储在某一媒体上,能够被识别的物理符号;   数据的概念在数据处理领域已经被大为拓宽,不仅包括字符组成的文本形式的数据,而且还

    2023年04月16日
    浏览(30)
  • SQLite数据库

    目录 SQLite数据库 在Android中的使用 SQLiteOpenHelper中的方法 增删改查 添加数据 insert() 查询数据 query(),rawQuery() 查询和添加案例 数据库帮助类: MainActivity: Activity_main.xml:         SQLite是一个 轻量级的嵌入数据库 ,实现了自给自足的、 无服务器 的、 零配置 的、事务性的

    2023年04月15日
    浏览(35)
  • SQLite学习(十二)SQLite《社区流动人员系统》项目实战,数据库创建

    在前面的博客中,我们学习了 SQLite 的理论知识,从本篇博客开始,同学们将通过一个实战项目**《社区流动人员系统》**,对之前所学的知识做一次实战应用。 随着社会经济的迅速崛起,城市一体化的步伐加快,大量农民选择转移到城市中就业。形成了一股数量巨大的流动性

    2024年02月08日
    浏览(86)
  • sqlite数据库基本使用

    sqlite数据库是sql数据库引擎的一种,它不需要任何配置,不需要服务器,是一个轻量级的嵌入式数据库。安装sqlite见文档:SQLite3的安装与使用_sqlite3安装_冒险的梦想家的博客-CSDN博客 下面直接对sqlite3数据库基本命令进行说明: 1.获取sqlite版本的命令 sqlite3 --version 2.数据库创

    2024年02月10日
    浏览(36)
  • 数据库--Sqlite3

     1、思维导图  2sqlite3在linux中是实现数据的增删,改 #includemyhead.h int main(int argc, const char *argv[]) {         //1、定义一个数据库句柄指针         sqlite3* ppDb =NULL;         //2、创建或打开数据库         if(sqlite3_open(\\\"./mydb.db\\\",ppDb)!=SQLITE_OK)         {                 printf(

    2024年04月27日
    浏览(37)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包