sqlite3 echo和'

编程入门 行业动态 更新时间:2024-10-25 19:25:18
sqlite3 echo和'<'管道命令无法按预期工作(sqlite3 echo and '<' piping command not working as expected)

我正在阅读一本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 database

Actually, 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

更多推荐

本文发布于:2023-08-07 22:25:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466019.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:echo

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!