一些很有用的SQLite命令总结

2023-12-07 0 427

显示表结构:
复制代码 代码如下:
sqlite> .schema [table]

获取所有表和视图:
复制代码 代码如下:
sqlite > .tables

获取指定表的索引列表:
复制代码 代码如下:
sqlite > .indices [table ]

导出数据库到 SQL 文件:
复制代码 代码如下:
sqlite > .output [filename ]
sqlite > .dump
sqlite > .output stdout

从 SQL 文件导入数据库:
复制代码 代码如下:
sqlite > .read [filename ]

格式化输出数据到 CSV 格式:
复制代码 代码如下:
sqlite >.output [filename.csv ]
sqlite >.separator ,
sqlite > select * from test;
sqlite >.output stdout

从 CSV 文件导入数据到表中:
复制代码 代码如下:
sqlite >create table newtable ( id integer primary key, value text );
sqlite >.import [filename.csv ] newtable

备份数据库:
复制代码 代码如下:
/* usage: sqlite3 [database] .dump > [filename] */
sqlite3 mytable.db .dump > backup.sql

恢复数据库:
复制代码 代码如下:
/* usage: sqlite3 [database ] < [filename ] */
sqlite3 mytable.db < backup.sql

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

悠久资源 SQLite 一些很有用的SQLite命令总结 https://www.u-9.cn/database/sqlite/121906.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务