一連のRDBMSインスタンス間のデータ移動関係シリーズ
今回はOracle版メモ。
移行元サーバからデータをエクスポート
exp "db_username/db_password@from_server file=dump.dmp tables=(table_a, table_b)"
移行先サーバへデータをインポート
imp "db_username/db_password@distination file=dump.dmp tables=(table_a, table_b)"
これも良く忘れるのでメモ。
PostgreSQLのダンプって、DDLとDMLをまんま吐いてくれるから便利。
リモートからやる場合は、PostgreSQLのバージョンをあわしておく必要がある。
移行先サーバにログイン
ssh username@destination_server
移行元サーバからデータをダンプ
pg_dump -U db_username -h fromserver -d db_name -p db_password -f ./dump.sql -v
ダンプしたデータをリストア
psql -U db_username -h localhost -d db_name < ./dump.sql
前回、PostgreSQLのCOPYコマンドの方がInsertより早い、のMySQL版。
SET NAMES utf8;
LOAD DATA INFILE '/path/to/file/data.csv'
INTO TABLE tablename FIELDS TERMINATED BY ',';
参考サイト
http://dev.mysql.com/doc/refman/4.1/ja/mysqlimport.html
http://dev.mysql.com/doc/refman/4.1/ja/load-data.html