UJP - 技術情報

Life is fun and easy!

不正IP報告数

Okan Sensor
 
メイン
ログイン
ブログ カテゴリ一覧

     

Oracle Unloader


Oracle Unloader


0.更新履歴

  • 2001.01.19 新規作成

1.はじめに

 このドキュメントでは,SQL*Plusを利用してOracleのテーブルデータをCSVファイルに出力する手順を示す.

 今回は,scott/tigerの練習用テーブルdeptを利用する.

2.手順

  • 次の様なUnload.sqlファイルを作成する

set head off
カラム名を表示しないようにする
set colsep ,
区切り文字をカンマにする
spool dept.csv
出力結果を書き出すファイルを指定する.
select * from dept;
アンロードするテーブルをSelectするSQL文を書く.
spool off
出力をとめる.
quit
SQL*Plusを終了する.

  • SQL*Plusを実行する.

db1% cat Unload.sql
set head off
set colsep ,
spool dept.csv
select * from dept;
spool off
quit
db1% sqlplus scott/tiger @Unload.sql

SQL*Plus: Release 8.1.5.0.0 - Production on Fri Jan 19 14:07:28 2001

(c) Copyright 1999 Oracle Corporation.  All rights reserved.


Connected to:
Oracle8i Enterprise Edition Release 8.1.5.0.0 - Production
With the Partitioning and Java options
PL/SQL Release 8.1.5.0.0 - Production


        10,ACCOUNTING    ,NEW YORK
        20,RESEARCH      ,DALLAS
        30,SALES         ,CHICAGO
        40,OPERATIONS    ,BOSTON

Disconnected from Oracle8i Enterprise Edition Release 8.1.5.0.0 - Production
With the Partitioning and Java options
PL/SQL Release 8.1.5.0.0 - Production
db1% cat dept.csv

        10,ACCOUNTING    ,NEW YORK
        20,RESEARCH      ,DALLAS
        30,SALES         ,CHICAGO
        40,OPERATIONS    ,BOSTON

db1%

3.サイレントモードで実行する

 画面に表示されないように実行する.

db1% sqlplus -s scott/tiger @Unload.sql

        10,ACCOUNTING    ,NEW YORK
        20,RESEARCH      ,DALLAS
        30,SALES         ,CHICAGO
        40,OPERATIONS    ,BOSTON

db1% sqlplus -s scott/tiger @Unload.sql > /dev/null
db1%

 -sオプションをつけると,SQL*Plusの起動メッセージが表示されない.
 しかし,/dev/nullをつけてしまえば関係ない.



広告スペース
Google