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