sqlite常用命令

173 阅读1分钟
CLP命令
.exit
.e
.tables
.schema [table name]
.indices [table name] 显示表的索引
sqlite_master系统视图
.mode col
.headers on

数据导出
.output file.sql
.dump
.output stdout

数据导入
.read file.sql

导出格式化
.output file.csv
.separator,
select * from tablename;
.output stdout

.output file.csv
.mode csv
select * from tablename;
.output stdout

attach语句:
attach '/home/xlx/app' as app;

------------------------
命令行

数据库备份
sqlite3 test.db .dump>test.sql

导入备份数据库
sqlite3 test.db < test.sql

SELECT datetime(1092941466, 'unixepoch', 'localtime');