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?

H2 Databaseで特定のテーブルをダンプする

Posted at

H2 Databaseで特定のテーブルをダンプするコマンドのメモです

組み込みモードで以下をコンソールから実行します。

java -cp h2.jar org.h2.tools.Script -url jdbc:h2:./<DBファイル名> -user sa -password <パスワード> -script <出力ファイル名>.sql -options table <テーブル名>

DBファイル名は拡張子を省略したものを書きます。
最後の-options引数にてテーブル名を指定します。複数テーブル指定するときは,でつないで、<テーブル名1>,<テーブル名2> のようにして指定します。

ツール仕様確認

Scriptツールの仕様はorg.h2.tools.Scriptのmain関数のJavaDocから確認できます。

このツールはH2 DatabaseのSQLコマンドにおけるSCRIPTコマンドを実行してくれる機能となっていて、上記でも利用している-options引数にはこのSCRIPTコマンドのオプションを指定できます。

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?