0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

bcpコマンドに関して

Posted at

皆さんこんにちは
今回はbcpコマンドについて説明していきます。

bcpコマンドでできることは、データベースにアクセスしてデータをエクスポートできたり、
逆にインポートして一括で登録することができます。

特に、画像データなど容量の重いデータをエクスポートしたりインポートしたりするときに便利です。

では、実際にbcpコマンドの構成を見てみましょう。

まずは、データをエクスポートする場合
bcp [データベース名].[スキーマ名].[テーブル名] out C:(任意の位置).csv -c -q -U "ユーザー名" -P "パスワード" -S "(自分のDBのIPアドレス) -t ","

次に、データをインポートする場合
bcp [データベース名].[スキーマ名].[テーブル名] in C:(任意の位置).csv -c -q -U "ユーザー名" -P "パスワード" -S "(自分のDBのIPアドレス) -t ","

以上が、今回自分が使用したbcpコマンドになります。
普段自分はエクスポートやインポートする際、SSMSの標準機能を用いてやっていましたが、画像ありのデータの場合すごく時間がかかったり、できない事象が発生しました。
そこで、今回bcpコマンドを使用したところ、一瞬でできたのでぜひ使ってみてください。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?