column today new_value today_file --定义列值保存到变量today_file中
select 'abc_'||to_char(sysdate,'yyyymmddhh24mi') as today from dual; --赋值列值
SPOOL /tmp/&&today_file..txt;
set serveroutput on;
--SQL程序块
spool off;
or
sqlplus中利用spool生成带日期的文件名
col spf new_value spf noprint
select 'd:'||to_char(sysdate,'yyyymmdd')||'.txt' spf from dual;
spo &spf
select * from dual;
spo off;