@echo off
set user_name=username
set password=
set sid=sid
@echo select distinct scid, to_char(dlog_on_timestamp,'dd-Mon-YYYY hh:mi:ss') from table where dlog_on_timestamp > sysdate-7; | sqlplus -s %user_name%/%password%@%sid% >> C:\Users\test.txt
在运行该批处理文件时,>符号创建了文件sysdate-7。但是我需要运行数据库查询,结果应该存储在test.txt中
答案 0 :(得分:1)
在命令周围为外壳程序(cmd.exe
加上引号)
@echo "select distinct scid, to_char(dlog_on_timestamp,'dd-Mon-YYYY hh:mi:ss') from table where dlog_on_timestamp > sysdate-7;" | sqlplus -s %user_name%/%password%@%sid% >> C:\Users\test.txt