EDB*Plusの使用

To open an EDB*Plus command line, navigate through the Applications or Start menu to the Advanced Server menu, to the Run SQL Command Line menu, and select the EDB*Plus option. You can also invoke EDB*Plus from the operating system command line with the following command:

edbplus [ -S[ILENT ] ] [ <login> | NOLOG ] [ @<scriptfile> [.<ext> ] ] -SILENT

指定した場合、EDB*Plusサインオンバナーはすべてのプロンプトとともに抑制されます。

login

データベースサーバーとデータベースに接続するためのログイン情報。 login は次の形式を取ります。ログイン情報内に空白があってはならないことに注意してください:

<username>[/<password>][@{<connectstring> | <variable> } ]

どこ:

  • username はデータベースへの接続に使用するデータベースのユーザー名です。

  • password は指定された*username*に関連付けられたパスワードです。*password*が提供されていないが、認証にパスワードが必要な場合、利用可能な場合はパスワードファイルが使用されます。パスワード・ファイルがないか、一致する接続パラメーターを持つパスワード・ファイルにエントリーがない場合、EDB*Plusはパスワードを求めるプロンプトを出します。

  • connectstring は次の形式のデータベース接続文字列です:

    <host> [:<port>][/ <dbname>][?ssl={true | false}]

    どこ:

  • host は、データベースサーバーが存在するホスト名またはIPアドレスです。@ connectstring も@ variable も /NOLOG も指定されていない場合、デフォルトのホストはローカルホストであると見なされます。

  • port はデータベースサーバーで接続を受信するポート番号です。指定しない場合、デフォルトは 5444 です。

  • dbname は接続するデータベースの名前です。指定しない場合のデフォルトは edb です。

  • IPv4の代わりに Internet Protocol version 6 (IPv6)が接続に使用されている場合、IPアドレスは角括弧で囲まれている必要があります(つまり、[ ipv6_address ])。以下は、IPv6接続を含む例です。

edbplus.sh enterprisedb/password@[fe80::20c:29ff:fe7c:78b2]:5444/edb

データベースサーバーの pg_hba.conf ファイルには、IPv6接続用の適切なエントリが含まれている必要があります。次の例は、すべてのアドレスを許可するエントリを示しています。

# TYPE DATABASE  USER  ADDRESS  METHOD
  host   all     all   ::0/0    md5

pg_hba.conf ファイルの詳細については、次のPostgreSQLコアのドキュメントを参照してください:

SSL接続が必要な場合は、接続文字列に ?ssl=true パラメータを含めます。このような場合、接続文字列には、/dbname*の有無にかかわらず、少なくとも*host:*port*を含める必要があります。sslパラメータが指定されていない場合、デフォルトは false です。SSL接続の設定方法については、セクション2.3を参照してください。

  • variable はデータベース接続文字列を含む login.sql ファイルで定義された変数です。 login.sql ファイルはAdvancedServerホームディレクトリの edbplus サブディレクトリにあります。

/NOLOG

データベース接続を確立せずにEDB*Plusを起動するには、 /NOLOG を指定します。データベース接続を必要とするSQLコマンドおよびEDB*Plusコマンドは、このモードでは使用できません。/NOLOGオプションを指定してEDB*Plusを起動した後、CONNECTコマンドを指定してデータベースに接続できます。

scriptfile/ [.<ext> ]

scriptfile is the name of a file residing in the current working directory, containing SQL and/or EDB*Plus commands that will be automatically executed after startup of EDB*Plus. ext is the filename extension. If the filename extension is sql, then the .sql extension may be omitted when specifying scriptfile. When creating a script file, always name the file with an extension, otherwise it will not be accessible by EDB*Plus. (EDB*Plus will always assume a .sql extension on filenames that are specified with no extension.)

次の例は、ポート 5444 の localhost 上のデータベースサーバーで実行されているデータベース edb に接続し、パスワード password を持つユーザー enterprisedb を示しています。

C:\Program Files\edb\as13\edbplus>edbplus enterprisedb/password
Connected to EnterpriseDB 13.0.1 (localhost:5444/edb) AS enterprisedb
EDB*Plus: Release 13 (Build 38.0.0)
Copyright (c) 2008-2017, EnterpriseDB Corporation. All rights reserved.
SQL>

次の例は、ポート 5445 の localhost 上のデータベースサーバーで実行されているデータベース edb に接続している、パスワード password を持つユーザー enterprisedb を示しています。

C:\Program Files\edb\as13\edbplus>edbplus enterprisedb/password@localhost:5445/edb
Connected to EnterpriseDB 13.0.1 (localhost:5445/edb) AS enterprisedb

EDB*Plus: Release 13 (Build 38.0.0)
Copyright (c) 2008-2017, EnterpriseDB Corporation. All rights reserved.

SQL>

次の例は、 login.sql ファイルで変数 hr_5445 を使用し、ポート 5445 で localhost のデータベース hr に接続する方法を示しています。

C:\Program Files\edb\as13\edbplus>edbplus enterprisedb/password@hr_5445
Connected to EnterpriseDB 13.0.1 (localhost:5445/hr) AS enterprisedb

EDB*Plus: Release 13 (Build 38.0.0)
Copyright (c) 2008-2017, EnterpriseDB Corporation. All rights reserved.

SQL>

以下は、前の例で使用された login.sql ファイルの内容です。

define edb="localhost:5445/edb"
define hr_5445="localhost:5445/hr"
次の例は、スクリプトファイル dept_query.sql を実行した後

ポート 5444 でサーバー localhost のデータベース edb に接続しています。

C:\Program Files\edb\as13\edbplus>edbplus enterprisedb/password @dept_query
Connected to EnterpriseDB 13.0.1 (localhost:5444/edb) AS enterprisedb

SQL> SELECT * FROM dept;

DEPTNO  DNAME          LOC
------- -------------- -------------
10      ACCOUNTING     NEW YORK
20      RESEARCH       DALLAS
30      SALES          CHICAGO
40      OPERATIONS     BOSTON

SQL> EXIT
Disconnected from EnterpriseDB Database.

以下は、前の例で使用されたファイル dept_query.sql の内容です。

SET PAGESIZE 9999
SET ECHO ON
SELECT * FROM dept;
EXIT