为什么我不能使用命令行创建这个 SQLite 视图?
Why can't I create this SQLite view using the command line?
当我在SQLiteStudio中运行下面的查询时,视图创建成功。
CREATE VIEW BeatsEventsView AS
SELECT BeatId,
EventId,
Hero,
Beat,
AdaptationPhase,
Essence,
Act,
Events.[Desc]
FROM BeatEvents,
Beats,
Events
WHERE (BeatEvents.EventId = Events.Id) AND
(BeatEvents.BeatId = Beats.Id);
但是,如果我将它放入文件中并运行下面的命令,我会得到 Error: near line 1: near "CREATE": syntax error
。
sqlite3 $DB_FILE < $BASE_DIR/src/BeatsEventsView.sql.txt
如何在 shell 脚本中创建此视图?
运行 命令 file BeatsEventsView.sql.txt
结果如下:
BeatsEventsView.sql.txt: UTF-8 Unicode (with BOM) text
感谢@Shawn 的帮助,我通过添加
修复了错误
-- -*- mode: sql; coding: utf-8 -*-
在文件的开头,使其看起来如下所示。
-- -*- mode: sql; coding: utf-8 -*-
CREATE VIEW BeatsEventsView AS
SELECT BeatId,
EventId,
...
用 Emacs 保存后,file BeatsEventsView.sql.txt
命令现在 returns
BeatsEventsView.sql.txt: ASCII text
当我在SQLiteStudio中运行下面的查询时,视图创建成功。
CREATE VIEW BeatsEventsView AS
SELECT BeatId,
EventId,
Hero,
Beat,
AdaptationPhase,
Essence,
Act,
Events.[Desc]
FROM BeatEvents,
Beats,
Events
WHERE (BeatEvents.EventId = Events.Id) AND
(BeatEvents.BeatId = Beats.Id);
但是,如果我将它放入文件中并运行下面的命令,我会得到 Error: near line 1: near "CREATE": syntax error
。
sqlite3 $DB_FILE < $BASE_DIR/src/BeatsEventsView.sql.txt
如何在 shell 脚本中创建此视图?
运行 命令 file BeatsEventsView.sql.txt
结果如下:
BeatsEventsView.sql.txt: UTF-8 Unicode (with BOM) text
感谢@Shawn 的帮助,我通过添加
修复了错误-- -*- mode: sql; coding: utf-8 -*-
在文件的开头,使其看起来如下所示。
-- -*- mode: sql; coding: utf-8 -*-
CREATE VIEW BeatsEventsView AS
SELECT BeatId,
EventId,
...
用 Emacs 保存后,file BeatsEventsView.sql.txt
命令现在 returns
BeatsEventsView.sql.txt: ASCII text