1. 导出SQL脚本
set linesize 2500
set echo off
set term off
set heading off
set pagesize 0
set trimspool on
set trimout on
set feedback off
spool 【文件物理地址,如c:\temp\test.cvs】
【SQL查询语句:表头 select ‘a,b,c,d’ from dual
数据 union select a||','||b||','||c from tablename】;
spool off
spool c:\temp\test1.cvs
select ‘a,b,c,d’ from dual union select name||','||sex||','||age||','||school from students1;
spool off
spool c:\temp\test2.cvs
select ‘a,b,c,d’ from dual union select name||','||sex||','||age||','||school from students2;
spool off
2. 在PL/SQL种运行脚本
SQL> @ 脚本物理地址;
SQL> @c:\sqls\export_csv.sql;