0
希望將結果輸出到多個csv文件並在每個文件的特定行號處截斷。嘗試以下,但不想創建多個查詢。oracle sqlplus通過行號將文件轉換爲多個文件
set colsep ,
DEFINE SPOOL_BASE_NAME = "spool"
DEFINE PAGE_SIZE = 10
DEFINE PAGE_NO = 1
DEFINE SPOOL_EXT=".csv"
SPOOL &SPOOL_BASE_NAME.&PAGE_NO.&SPOOL_EXT
SELECT *
FROM (SELECT a.*,rownum rnum
FROM (SELECT username, account_status,DEFAULT_TABLESPACE,TEMPORARY_TABLESPACE FROM dba_users order by username) a
WHERE rownum <= &PAGE_SIZE * &PAGE_NO)
WHERE rnum >= &PAGE_SIZE * (&PAGE_NO - 1) + 1;
SPOOL OFF
DEFINE PAGE_NO = 2
SPOOL &SPOOL_BASE_NAME.&PAGE_NO
SELECT *
FROM (SELECT a.*,rownum rnum
FROM (SELECT username, account_status,DEFAULT_TABLESPACE,TEMPORARY_TABLESPACE FROM dba_users order by username) a
WHERE rownum <= &PAGE_SIZE * &PAGE_NO)
WHERE rnum >= &PAGE_SIZE * (&PAGE_NO - 1) + 1;
SPOOL OFF
你有使用' SQL * Plus「呢?從'SQL * Plus'創建單個文件似乎容易得多,然後有一個調用「SQL * Plus」的批處理腳本,然後將文件分解爲更小的塊。或者使用'utl_file'從循環內生成文件。 –
即時通訊使用Linux,該批處理文件是什麼樣子? – Dom
它可能就像'split -l <> file_name'一樣簡單,其中'<>'是每個文件所需的行數http://www.theunixschool.com/2012/10/10-examples-of-split -command功能於unix.html –