sal*_*l17 1 sql sql-workbench-j
我正在Windows机器上运行,尝试通过在批处理模式下运行SQL Workbench来导出查询结果.阅读SQL Workbench文档后,听起来WbExport是从查询中导出结果的最佳命令.
另一个要求是我想要运行的查询是在外部.sql文件中.同样,根据SQL文档,在批处理模式下,我可以使用WbInclude命令或-script参数从外部.sql文件运行查询.但是,我无法使用WbExport正常工作.我已经尝试使用sqlwbconsole64.exe和sqlworkbench.jar在批处理模式下运行SQL Workbench.请参阅以下四个示例:
java -jar sqlworkbench.jar -profile='connection-profile' -command='WbExport -file=test_export.txt -type=text -delimiter=\t; WbInclude test.sql;'
java -jar sqlworkbench.jar -profile='connection-profile' -command='WbExport -file=test_export.txt -type=text -delimiter=\t' -script='test.sql'
sqlwbconsole64 -profile='connection-profile' -command='WbExport -file=test_export.txt -type=text -delimiter=\t; WBInclude test.sql;'
sqlwbconsole64 -profile='connection-profile' -command='WbExport -file=test_export.txt -type=text -delimiter=\t' -script='test.sql'
Run Code Online (Sandbox Code Playgroud)
在此先感谢您的帮助!
您不能WbInclude用作WbExport命令的"源".您需要将所有内容放入单个SQL脚本中:
档案export.sql:
WbExport -file=test_export.txt -type=text -delimiter=\t;
select *
from the_table;
Run Code Online (Sandbox Code Playgroud)
或者,如果您只想导出单个表,请使用:
WbExport -file=test_export.txt -type=text -delimiter=\t -sourceTable=the_table;
Run Code Online (Sandbox Code Playgroud)
然后跑
java -jar sqlworkbench.jar -profile='connection-profile' -script=export.sql
Run Code Online (Sandbox Code Playgroud)
(顺便说一句:如果-script指定,-command则被忽略)