【发布时间】:2012-06-09 18:35:22
【问题描述】:
我有一个名为 schema.sql 的文件,它看起来像这样:
drop table if exists codes;
create table paste_codes (
id integer primary key autoincrement,
codetitle string not null,
codebody string not null,
pub_date string not null
)
有什么方法可以让 sqlite3 从这个文件中读取它并为我创建数据库? 像 cat schema.sql > sqlite3 /tmp/database.db 之类的东西?
谢谢
【问题讨论】:
-
请注意:SQL 文件指示创建表,而不是数据库。有很大的不同。
-
可能想看看stackoverflow.com/questions/489277/…(不知道更简单的方法)
-
哦,我认为一个简单的管道方式就可以完成这项工作,一个完整的 sh 代码!谢谢小伙伴们!西蒙,谢谢,我会好好看看!