当我在SQLPlus中运行以下语句时
SET PAGESIZE 50000
SET LINESIZE 250
SET NUMWIDTH 5
SET FEEDBACK OFF
set echo off
set heading on
set headsep off
set wrap off
SET COLSEP ";"
SPOOL clients.csv
SELECT id, name, age FROM clients;
我有类似的东西:
id;name;age
1;Alex;22
2;Adam;36
3;Cody;27
但是有可能得到这样的输出:
id;name;age;1;Alex;22;2;Adam;36;3;Cody;27
所以我只希望所有值都用';'分隔甚至是列名,我都希望“当您获得所有列时不要使用ENTER,而应使用“;”代替”。
您可以通过多种方式进行操作,但问题是为什么要这样做?
Select * from table pivot (sum(id)
for id in (1,2,3))
pivot (max(name)
for name in ('Alex' , 'Adam' , 'cody' ))
pivot (max(age)
for age in (22,36,27))