1.查詢某張表的所有字段名
select COLUMN_NAME,column_id from user_tab_columns where table_name='SYS_USER‘;
表名必須大寫,否則查不出來
2.查詢出某張表所有字段名,用 ||','|| 分隔
select max(substr(SYS_CONNECT_BY_PATH(COLUMN_NAME,'||'',''||'),2)) col from (select COLUMN_NAME,column_id from user_tab_columns where table_name='SYS_USER') start with column_id=1 connect by column_id=rownum;
這個用來spool導出數據時,手動定義格式(字段較多時,可以用此語句查出所有字段)
3.spool 導出csv
spool.sql
set colsep ,
set feedback off
set heading off
set trimout on
set termout off
set pagesize 0
spool /home/oracle/spool_data/test.csv
select user_name || ',' || user_pass from sys_user_account;
spool off
exit
sqlplus -s 用戶名/密碼 @spool.sql
