1
當我使用命令java -jar sqltool.jar --rcFile sqltool.rc db_file q.sql
運行HSQLDB 2.2.5下面的腳本中,我得到了以下錯誤消息:如何在HSQLDB導出命令中啓用轉義?
錯誤消息:
SEVERE Error at 'q3.sql' line 16:
"\xq SELECT "T1"."C1", "T1"."C2" FROM "PUBLIC"."TABLE1" "T1""
Export syntax: "\x table_or_view_name " OR "\x SELECT statement".
(Do not end with ';', since the \x command itself is not SQL).
SEVERE Rolling back SQL transaction.
org.hsqldb.cmdline.SqlTool$SqlToolException
HSQLDB腳本:
--q.sql
DROP TABLE "PUBLIC"."TABLE1" IF EXISTS;
CREATE TABLE "PUBLIC"."TABLE1" (
"C1" VARCHAR(10),
"C2" VARCHAR(10),
"C3" VARCHAR(10)
);
INSERT INTO "PUBLIC"."TABLE1" ("C1", "C2", "C3") VALUES (',', 'b', 'c');
INSERT INTO "PUBLIC"."TABLE1" ("C1", "C2", "C3") VALUES ('d', 'e', 'f');
* *DSV_COL_DELIM=,
* *DSV_ROW_DELIM=\n
* *DSV_TARGET_FILE=results.csv
\xq SELECT "T1"."C1", "T1"."C2" FROM "PUBLIC"."TABLE1" "T1"
注如果我使用\x
而不是\xq
,則上述HSQLDB腳本可以成功運行。但是,\x
命令不會從數據中跳出「,
」字符。但是,根據HSQLDB manual,\xq
應該在輸入中跳過分隔符。
如何將HSQLDB表導出爲CSV文件,並在需要時跳過分隔符?
我從hsqldb.org/support/hsqldb_16.zip獲得了HSQLDB 2.2.6的預發佈快照,併成功運行了我的腳本。謝謝! – reprogrammer
不客氣。你能把我的答案投票嗎? – Blaine