Hatena::ブログ(Diary)

ablog このページをアンテナに追加 RSSフィード Twitter

2017-08-11

SQL Workbench/J のコンソールモードを使う

環境


インストール


設定

  • GUIで起動する。
$ cd Workbench-Build122
$ sh ./sqlworkbench.sh

コンソールモードで接続する

$ cd Workbench-Build122
$ sh ./sqlwbconsole.sh -profile=Redshift ★GUI で設定したプロファイル名を指定
readlink: illegal option -- f
usage: readlink [-n] [file ...]

SQL Workbench/J (122) console interface started.
Enter exit to quit.
Enter WbHelp for a list of SQL Workbench/J specific commands
Config directory: /Users/******/.sqlworkbench

Connection to "User=master, Schema=public, URL=jdbc:redshift://***.***.ap-northeast-1.redshift.amazonaws.com:5439/mydb" successful

master@public> select * from PG_TABLE_DEF limit 10;

schemaname | tablename                | column       | type           | encoding | distkey | sortkey | notnull
-----------+--------------------------+--------------+----------------+----------+---------+---------+--------
pg_catalog | padb_config_harvest      | name         | character(136) | lzo      | false   |       0 | true
pg_catalog | padb_config_harvest      | harvest      | integer        | lzo      | false   |       0 | true
pg_catalog | padb_config_harvest      | archive      | integer        | lzo      | false   |       0 | true
pg_catalog | padb_config_harvest      | directory    | character(500) | lzo      | false   |       0 | true
pg_catalog | pg_aggregate             | aggfnoid     | regproc        | none     | false   |       0 | true
pg_catalog | pg_aggregate             | aggtransfn   | regproc        | none     | false   |       0 | true
pg_catalog | pg_aggregate             | aggfinalfn   | regproc        | none     | false   |       0 | true
pg_catalog | pg_aggregate             | aggtranstype | oid            | none     | false   |       0 | true
pg_catalog | pg_aggregate             | agginitval   | text           | none     | false   |       0 | false
pg_catalog | pg_aggregate_fnoid_index | aggfnoid     | regproc        | none     | false   |       0 | false

(10 Rows)
SELECT executed successfully

master@public>
master@public> \q
$

補足

$ cat sqlwbconsole.sh
#!/bin/sh
# Start SQL Workbench/J in console mode

SCRIPT_PATH="$(dirname "$(readlink -f "$0")")"

JAVACMD="java"

if [ -x "$SCRIPT_PATH/jre/bin/java" ]
then
  JAVACMD="$SCRIPT_PATH/jre/bin/java"
elif [ -x "$WORKBENCH_JDK/bin/java" ]
then
  JAVACMD="$WORKBENCH_JDK/bin/java"
elif [ -x "$JAVA_HOME/jre/bin/java" ]
then
  JAVACMD="$JAVA_HOME/jre/bin/java"
elif [ -x "$JAVA_HOME/bin/java" ]
then
  JAVACMD="$JAVA_HOME/bin/java"
fi

cp=$SCRIPT_PATH/sqlworkbench.jar
cp=$cp:$SCRIPT_PATH/dom4j-1.6.1.jar
cp=$cp:$SCRIPT_PATH/poi-ooxml-schemas.jar
cp=$cp:$SCRIPT_PATH/poi-ooxml.jar
cp=$cp:$SCRIPT_PATH/poi.jar
cp=$cp:$SCRIPT_PATH/stax-api-1.0.1.jar
cp=$cp:$SCRIPT_PATH/resolver.jar
cp=$cp:$SCRIPT_PATH/serializer.jar
cp=$cp:$SCRIPT_PATH/simple-odf.jar
cp=$cp:$SCRIPT_PATH/ext/*

$JAVACMD -Djava.awt.headless=true \
         -Xmx1024m \
         -Dvisualvm.display.name=SQLWorkbench \
         -cp $cp workbench.console.SQLConsole "$@"

参考

*1:[Download package for MacOS] ではない

スパム対策のためのダミーです。もし見えても何も入力しないでください
ゲスト


画像認証

トラックバック - http://d.hatena.ne.jp/yohei-a/20170811/1502459059