1. 程式人生 > >除錯經驗——使用SQLPLUS將查詢結果匯出到Excel

除錯經驗——使用SQLPLUS將查詢結果匯出到Excel

問題描述:

今天發現一個SQL指令碼在Toad中報錯,但在SQLPLUS中卻可成功執行。

問題隨之而來,在SQLPLUS中如何將查詢結果匯出到Excel中呢?

方法如下:

Export SQL Results To Excel Using SQLPLUS

  1. Step 1: Login into database using SQL PLUS.
  2. Step 2: Set markup using below command. SET MARKUP HTML ON.
  3. Step 3: Spool the output to a file. SPOOL C:MYOUTPUT.XLS.
  4. Step 4: Run your SQL Query. SQL QUERY.
  5. Step 5: Set the Spool Off.
  6. Step 6: Open the output XLS file to view the output.

其中,SET MARKUP HTML ON第一次使用。