DB2 importコマンドの利用目的別にオプションの使い分けメモ。
以下、import.csv を sampleテーブルに登録する例
文字コード指定
modified by codepage=xxxxで指定
import from import.csv of del of del modified by codepage=1208 insert into sample
codepage=1208はUTF-8
改行付データ
modified by delprioritycharを利用。
字区切りの優先順位を変えてくれる。
デフォルト優先順位は、(1) レコード区切り文字、(2) 区切り文字、(3) 列区切り文字。
この修飾子を使用すると、区切り文字の優先順位が (1) 区切り文字、(2) レコード区切り文字、(3) 列区切り文字にとなる
import from import.csv of del of del modified by delprioritychar insert into sample
デフォルト値を利用
列のデフォルト値を設定する場合のオプション。
modified by usedefaultsを利用する。
import from import.csv of del of del modified by usedefaults insert into sample
identity列のimport
フィールドでidentity列を利用している場合※、Importファイルの内容に整合性がないとエラーになります。
※ddl ex. field1 int generated by default as identity
そんな時は、modified by identityignoreを指定すると、Importファイルの内容を無視して、 ID値を生成してくれます。
import from import.csv of del of del modified by identityignore insert into sample
コミット単位を指定する
アクティブログフルには要注意。
import from import.csv of del of del commitcount xxxxx modified by xxxx insert into sample