创建一个文件文件,在里面编辑要导出的内容
文件的名称是 emp_sal.txt
-- suppress sql output in results
set echo off
-- eliminate row count message at end
set feedback off
-- make line long enough to hold all row data
set linesize 1000
-- suppress headings and page breaks
set pagesize 0
-- eliminate SQL*Plus prompts from output
set sql prompt ''
-- eliminate trailing blanks
set trimspool on
-- send output to file
spool C:\Users\Administrator\Desktop\emp_sal.csv
select '"员工编号","名字","姓氏","薪资"' from dual
union all
select employee_id||',"'||last_name||'","'||first_name||'",'||salary from employees;
spool off
exit
在SQL Plus里面调用编辑的脚本
C:\Users\Administrator>sqlplus scott/tiger
SQL*Plus: Release 11.2.0.1.0 Production on 星期四 3月 17 10:13:49 2016
Copyright (c) 1982, 2010, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> @C:\Users\Administrator\Desktop\emp_sal.txt
使用excel打开生成的文件
文件的名称是 emp_sal.txt
-- suppress sql output in results
set echo off
-- eliminate row count message at end
set feedback off
-- make line long enough to hold all row data
set linesize 1000
-- suppress headings and page breaks
set pagesize 0
-- eliminate SQL*Plus prompts from output
set sql prompt ''
-- eliminate trailing blanks
set trimspool on
-- send output to file
spool C:\Users\Administrator\Desktop\emp_sal.csv
select '"员工编号","名字","姓氏","薪资"' from dual
union all
select employee_id||',"'||last_name||'","'||first_name||'",'||salary from employees;
spool off
exit
在SQL Plus里面调用编辑的脚本
C:\Users\Administrator>sqlplus scott/tiger
SQL*Plus: Release 11.2.0.1.0 Production on 星期四 3月 17 10:13:49 2016
Copyright (c) 1982, 2010, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> @C:\Users\Administrator\Desktop\emp_sal.txt
使用excel打开生成的文件
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26506993/viewspace-2058605/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/26506993/viewspace-2058605/