SQLite是一款实现了自包含、无服务器、零配置、事务性SQL数据库引擎的软件库。SQLite是世界上部署最广泛的SQL数据库引擎。
SQLite 是非常小的,是轻量级的,完全配置时小于 400KiB,省略可选功能配置时小于250KiB。
SQLite 源代码不受版权限制。
Dbeaver等工具支持数据表导出为sql文件,但无法直接将数据库导出至整个sql文件中
。
.\sqlite-\sqlite3.exe db.healthclub .dump > ..\YouliTest\HeaClub.sql
.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" "我想减肥" "有没有朋友一起减肥呢?
" "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>