[20190731]spool cvs in 12cR2.txt

lfree發表於2019-07-31

[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/,如需轉載,請註明出處,否則將追究法律責任。