在 Windows 中将 .sql 文件重定向到 .db 文件 [英] Redirecting a .sql file to .db file in Windows

查看:80
本文介绍了在 Windows 中将 .sql 文件重定向到 .db 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图通过在 Learn SQL the Hard Way 站点上做练习来学习 SQL.我在桌面上的文件夹中创建了一个名为 ex1.sql 的文件,并将所有 sqlite3 的东西都放在了 PATH 中.但是,我使用的是 Windows Powershell,无法执行命令:

I have been trying to learn SQL by doing the exercises on the Learn SQL the Hard Way site. I have made a file in folder on my desktop called ex1.sql, and I have put all of the sqlite3 stuff in PATH. However, I am using Windows Powershell and I cannot perform the command:

sqlite3 ex1.db < ex1.sql

我在 Powershell 终端中收到此错误:

I am getting this error in the Powershell terminal:

At line:1 char:16
+ sqlite3 ex1.db < ex1.sql
+                ~
The '<' operator is reserved for future use.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : RedirectionNotSupport

所以,我猜'<'只能用于在 Unix 操作系统上重定向.我试图在 powershell 中找到一个等效的命令,但我还没有找到.如果有人遇到过这个问题或知道如何将 .sql 文件重定向到 .db,那就太好了.

So, I guess '<' can only be used to redirect on Unix OS. I have tried to find an equivalent command in powershell, but I have not found one yet. If anyone has had this problem or knows how to redirect .sql files to .db, then that would be great.

推荐答案

你可以试试:

get-content ext1.sql | sqllite3 ext1.db

这篇文章很好地讨论了 Powershell 中的遗留重定向问题和各种解决方法:

The article has a nice discussion of legacy redirection issues in Powershell and various workarounds:

http://blogs.technet.com/b/heyscriptingguy/archive/2011/07/16/working-around-legacy-redirection-issues-with-powershell.aspx

这篇关于在 Windows 中将 .sql 文件重定向到 .db 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆