我正在阅读一本SQL书 ,作者正在使用Sqlite3,这很棒,因为没有服务器可以搞乱。
在作者所说的书中输入:
sqlite3 -echo something.db < some.sql
问题是没有任何东西回到终端,甚至没有从'''重定向命令创建的数据库。
有谁知道发生了什么......有这个?
I am reading a SQL book and the author is using Sqlite3, which is awesome because there is not a server to mess with.
In the book the author says to type:
sqlite3 -echo something.db < some.sql
The problem is nothing ever echos out to the terminal nor is there even a database created from the '<' redirection command.
Does anyone know what is going on...with this?
最满意答案
实际上,您显示的命令是从sql dump创建新数据库的正确方法。
你能否展示你的sql文件内容( cat some.sql )? 我可以重现所描述的行为的唯一方法是向sqlite提供一个空的sql文件。
尝试此命令,看看是否可以得到相同的结果:
$ cat <<EOF > test.sql > create table test1 (f1, f2, f3); > insert into test1(f1, f2, f3) values ("foo", "bar", "baz"); > EOF $ sqlite3 -echo test.db < test.sql create table test1 (f1, f2, f3); insert into test1(f1, f2, f3) values ("foo", "bar", "baz"); $ file test.db test.db: SQLite 3.x databaseActually, the command you show IS a proper way of creating a new database from sql dump.
Can you please show your sql file contents (cat some.sql)? The only way I can reproduce the behavior described is by feeding sqlite an empty sql file.
Try this commands and see if you can get the same result:
$ cat <<EOF > test.sql > create table test1 (f1, f2, f3); > insert into test1(f1, f2, f3) values ("foo", "bar", "baz"); > EOF $ sqlite3 -echo test.db < test.sql create table test1 (f1, f2, f3); insert into test1(f1, f2, f3) values ("foo", "bar", "baz"); $ file test.db test.db: SQLite 3.x database更多推荐
发布评论