ITPub博客

首页 > 数据库 > Oracle > [20190731]spool cvs in 12cR2.txt

[20190731]spool cvs in 12cR2.txt

原创 Oracle 作者:lfree 时间:2019-07-31 21:08:45 0 删除 编辑

[20190731]spool cvs in 12cR2.txt

--//12c支持cvs输出。语法如下:
SET MARKUP CSV {ON|OFF} [DELIMI[TER] character] [QUOTE {ON|OFF}]

1.环境:

SCOTT@test01p> @ ver1
PORT_STRING                    VERSION        BANNER                                                                               CON_ID
------------------------------ -------------- -------------------------------------------------------------------------------- ----------
IBMPC/WIN_NT64-9.1.0           12.2.0.1.0     Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production              0

2.测试:
SCOTT@test01p> SET MARKUP CSV ON
SCOTT@test01p> select * from dept;
"DEPTNO","DNAME","LOC"
10,"ACCOUNTING","NEW YORK"
20,"RESEARCH","DALLAS"
30,"SALES","CHICAGO"
40,"OPERATIONS","BOSTON"

--//取消字符串的引号。
SCOTT@test01p> SET MARKUP CSV ON QUOTE OFF
SCOTT@test01p> select * from dept;
DEPTNO,DNAME,LOC
10,ACCOUNTING,NEW YORK
20,RESEARCH,DALLAS
30,SALES,CHICAGO
40,OPERATIONS,BOSTON

--//使用|作为分割符号。
SET MARKUP CSV ON DELIMITER |

SCOTT@test01p> select * from dept;
DEPTNO|DNAME|LOC
10|ACCOUNTING|NEW YORK
20|RESEARCH|DALLAS
30|SALES|CHICAGO
40|OPERATIONS|BOSTON

SCOTT@test01p> set head off
SCOTT@test01p> select * from dept;
10|ACCOUNTING|NEW YORK
20|RESEARCH|DALLAS
30|SALES|CHICAGO
40|OPERATIONS|BOSTON

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

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    2471
  • 访问量
    6279103