ITPub博客

首页 > Linux操作系统 > Linux操作系统 > oracle query output in excel file

oracle query output in excel file

原创 Linux操作系统 作者:season0891 时间:2011-10-21 17:22:18 0 删除 编辑
Code:
SQL> spool emp.xls
SQL> select empno||chr(9)||ename||chr(9)||job||chr(9)||mgr from emp;
SQL> spool off

Code:
SET MARKUP HTML ON ENTMAP ON SPOOL ON PREFORMAT OFF ;
SPOOL MY_TEST_FILE.xls;
SELECT * FROM EMP;
SPOOL OFF;

Code:
set heading off pages 0 trimspool on feedback off echo off
spool c:\emp.xls
select 'EMPNO'||chr(9)||'ENAME'||chr(9)||'JOB'||chr(9)||'MGR' from dual
union all
select empno||chr(9)||ename||chr(9)||job||chr(9)||mgr from emp;
spool off

Then, from the SQL prompt:


Code:
test@ORA10G>
test@ORA10G> host type c:\test.sql
set heading off pages 0 trimspool on feedback off echo off
spool c:\emp.xls
select 'EMPNO'||chr(9)||'ENAME'||chr(9)||'JOB'||chr(9)||'MGR' from dual
union all
select empno||chr(9)||ename||chr(9)||job||chr(9)||mgr from emp;
spool off
test@ORA10G>
test@ORA10G> @c:\test.sql
EMPNO   ENAME   JOB     MGR
7369    SMITH   CLERK   7902
7499    ALLEN   SALESMAN        7698
7521    WARD    SALESMAN        7698
7566    JONES   MANAGER 7839
7654    MARTIN  SALESMAN        7698
7698    BLAKE   MANAGER 7839
7782    CLARK   MANAGER 7839
7788    SCOTT   ANALYST 7566
7839    KING    PRESIDENT
7844    TURNER  SALESMAN        7698
7876    ADAMS   CLERK   7788
7900    JAMES   CLERK   7698
7902    FORD    ANALYST 7566
7934    MILLER  CLERK   7782
test@ORA10G>


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/90618/viewspace-709490/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-06-10

  • 博文量
    790
  • 访问量
    2098024