加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

sqlite3:从命令行将模式转储到.sql文件中

发布时间:2020-12-12 19:05:26 所属栏目:百科 来源:网络整理
导读:我试图从OS X中的命令行将test.db的模式(即没有数据)转储到名为schema.sql的文件中,而不启动sqlite3. 我知道我能做到: sqlite3.open test.db.output schema.sql.schema.quit 但是我不想启动sqlite 3.这…… echo '.output schema.sql' | sqlite3 test.db 创
我试图从OS X中的命令行将test.db的模式(即没有数据)转储到名为schema.sql的文件中,而不启动sqlite3.

我知道我能做到:

sqlite3
.open test.db
.output schema.sql
.schema
.quit

但是我不想启动sqlite 3.这……

echo '.output schema.sql' | sqlite3 test.db

创建空文件,但这…

echo '.schema' | sqlite3 test.db

仅打印架构.如何从终端将其写入该文件?

谢谢!

shell允许重定向,sqlite3可以将命令作为参数获取:
sqlite3 test.db .schema > schema.sql

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读