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:
username is a database username with which to connect to the database.
password is the password associated with the specified
username. If a
password is not provided, but a password is required for authentication, a password file is used if available. If there is no password file or no entry in the password file with the matching connection parameters, then
EDB*Plus will prompt for the password. For more information on using password files and authentication methods, see Section
2.4.6.
connectstring is the database connection string with the following format:
host[:port][/dbname][?ssl={true | false}]
host is the hostname or IP address on which the database server resides. If neither
@connectstring nor
@variable nor
/NOLOG is specified, the default host is assumed to be the localhost.
port is the port number receiving connections on the database server. If not specified, the default is 5444.
dbname is the name of the database to connect to. If not specified the default is
edb. If
Internet Protocol version 6 (IPv6) is used for the connection instead of IPv4, then the IP address must be enclosed within square brackets (that is,
[ipv6_address]). The following is an example using an IPv6 connection:
The pg_hba.conf file for the database server must contain an appropriate entry for the IPv6 connection. The following example shows an entry that allows all addresses:
If an SSL connection is desired, then include the ?ssl=true parameter in the connection string. In such a case, the connection string must minimally include
host:port, with or without
/dbname. If the
ssl parameter is not specified, the default is
false. See Section
2.3 for instructions on setting up an SSL connection.
variable is a variable defined in the
login.sql file that contains a database connection string. The
login.sql file can be found in the
edbplus subdirectory of the
Advanced Server home directory.
Specify /NOLOG to start
EDB*Plus without establishing a database connection.
SQL commands and
EDB*Plus commands that require a database connection cannot be used in this mode. The
CONNECT command can be subsequently given to connect to a database after starting
EDB*Plus with the
/NOLOG option.
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.)
Using variable hr_5445 in the
login.sql file, the following illustrates how it is used to connect to database
hr on localhost at port 5445.
The ACCEPT command displays a prompt and waits for the user’s keyboard input. The value input by the user is placed in the specified variable.
APPEND is a line editor command that appends the given text to the end of the current line in the
SQL buffer.
In the following example, a SELECT command is built-in the
SQL buffer using the
APPEND command. Note that two spaces are placed between the
APPEND command and the
WHERE clause in order to separate
dept and
WHERE by one space in the
SQL buffer.
CHANGE is a line editor command performs a search-and-replace on the current line in the
SQL buffer.
If to/ is specified, the first occurrence of text
from in the current line is changed to text
to. If
to/ is omitted, the first occurrence of text
from in the current line is deleted.
The CLEAR command removes the contents of the
SQL buffer, deletes all column definitions set with the
COLUMN command, or clears the screen.
The COLUMN command controls output formatting. The formatting attributes set by using the
COLUMN command remain in effect only for the duration of the current session.
If the COLUMN command is specified with no subsequent options, formatting options for current columns in effect for the session are displayed.
If the COLUMN command is followed by a column name, then the column name may be followed by one of the following:
The CLEAR option reverts all formatting options back to their defaults for
column. If the
CLEAR option is specified, it must be the only option specified.
n is a positive integer that specifies the column width in characters within which to display the data. Data in excess of
n will wrap around with the specified column width.
If OFF is specified, formatting options are reverted back to their defaults, but are still available within the session. If
ON is specified, the formatting options specified by previous
COLUMN commands for
column within the session are re-activated.
username is a database username with which to connect to the database.
password is the password associated with the specified
username. If a
password is not provided, but a password is required for authentication, a search is made for a password file, first in the home directory of the Linux operating system account invoking EDB*Plus (or in the
%APPDATA%\postgresql\ directory for Windows) and then at the location specified by the
PGPASSFILE environment variable. The password file is
.pgpass on Linux hosts and
pgpass.conf on Windows hosts. The following is an example on a Windows host:
Note: When a password is not required, EDB*Plus does not prompt for a password such as when the
trust authentication method is specified in the
pg_hba.conf file. For more information about the
pg_hba.conf file and authentication methods, see the PostgreSQL core documentation at:
connectstring is the database connection string. See Section
2.2 for further information on the database connection string.
variable is a variable defined in the
login.sql file that contains a database connection string. The
login.sql file can be found in the
edbplus subdirectory of the
Advanced Server home directory.
The DEFINE command creates or replaces the value of a
user variable (also called a
substitution variable).
If the DEFINE command is given without any parameters, all current variables and their values are displayed.
If DEFINE variable is given, only
variable is displayed with its value.
DEFINE variable = text assigns
text to
variable.
text may be optionally enclosed within single or double quotation marks. Quotation marks must be used if
text contains space characters.
Note: The variable
EDB is read from the
login.sql file located in the
edbplus subdirectory of the
Advanced Server home directory.
DEL is a line editor command that deletes one or more lines from the
SQL buffer.
n is an integer representing the
nth line
n and
m are integers where
m is greater than
n representing the
nth through the
mth lines
The DESCRIBE command displays:
The DESCRIBE command will also display the structure of the database object referred to by a synonym. The syntax is:
The DISCONNECT command closes the current database connection, but does not terminate
EDB*Plus.
The EDIT command invokes an external editor to edit the contents of an operating system file or the
SQL buffer.
filename is the name of the file to open with an external editor.
ext is the filename extension. If the filename extension is
sql, then the
.sql extension may be omitted when specifying
filename.
EDIT always assumes a
.sql extension on filenames that are specified with no extension. If the filename parameter is omitted from the
EDIT command, the contents of the
SQL buffer are brought into the editor.
The EXECUTE command executes an SPL procedure from
EDB*Plus.
The EXIT command terminates the
EDB*Plus session and returns control to the operating system.
QUIT is a synonym for
EXIT. Specifying no parameters is equivalent to
EXIT SUCCESS COMMIT.
If COMMIT is specified, uncommitted updates are committed upon exit. If
ROLLBACK is specified, uncommitted updates are rolled back upon exit. The default is
COMMIT.
The GET command loads the contents of the given file to the
SQL buffer.
filename is the name of the file to load into the
SQL buffer.
ext is the filename extension. If the filename extension is
sql, then the
.sql extension may be omitted when specifying
filename.
GET always assumes a
.sql extension on filenames that are specified with no extension.
If LIST is specified, the content of the
SQL buffer is displayed after the file is loaded. If
NOLIST is specified, no listing is displayed. The default is
LIST.
The HELP command obtains an index of topics or help on a specific topic. The question mark (
?) is synonymous with specifying
HELP.
The HOST command executes an operating system command from
EDB*Plus.
The INPUT line editor command adds a line of text to the
SQL buffer after the current line.
LIST is a line editor command that displays the contents of the SQL buffer.
L[IST] [ n | n m | n * | n L[AST] | * | * n | * L[AST] | L[AST] ]
n represents the buffer line number.
n m displays a list of lines between
n and
m.
n * displays a list of lines that range between line
n and the current line.
n L[AST] displays a list of lines that range from line
n through the last line in the buffer.
* displays the current line.
* n displays a list of lines that range from the current line through line
n.
* L[AST] displays a list of lines that range from the current line through the last line.
L[AST] displays the last line.
Use the PASSWORD command to change your database password.
The PAUSE command displays a message, and waits for the user to press
ENTER.
optional_text specifies the text that will be displayed to the user. If the
optional_text is omitted, Advanced Server will display two blank lines. If you double quote the
optional_text string, the quotes will be included in the output.
The PROMPT command displays a message to the user before continuing.
message_text specifies the text displayed to the user. Double quote the string to include quotes in the output.
The QUIT command terminates the session and returns control to the operating system.
QUIT is a synonym for
EXIT.
Use REMARK to include comments in a script.
Use the SAVE command to write the SQL Buffer to an operating system file.
SAV[E] file_name
[CRE[ATE] | REP[LACE] | APP[END]]
file_name specifies the name of the file (including the path) where the buffer contents are written. If you do not provide a file extension,
.sql is appended to the end of the file name.
Include the CREATE keyword to create a new file. A new file is created
only if a file with the specified name does not already exist. This is the default.
Include the REPLACE keyword to specify that Advanced Server should overwrite an existing file.
Include the APPEND keyword to specify that Advanced Server should append the contents of the SQL buffer to the end of the specified file.
Use the SET command to specify a value for a session level variable that controls EDB*Plus behavior. The following forms of the
SET command are valid:
Use the SET AUTOCOMMIT command to specify
commit behavior for Advanced Server transactions.
Specify ON to turn
autocommit behavior on.
Specify OFF to turn
autocommit behavior off.
Include a value for statement_count to instruct EDB*Plus to issue a commit after the specified count of successful SQL statements.
Use the SET COLUMN SEPARATOR command to specify the text that Advanced Server displays between columns.
Use the SET ECHO command to specify if SQL and EDB*Plus script statements should be displayed onscreen as they are executed.
The SET FEEDBACK command controls the display of interactive information after a SQL statement executes.
Specify an integer value for row_threshold. Setting
row_threshold to
0 is same as setting
FEEDBACK to
OFF. Setting
row_threshold equal
1 effectively sets
FEEDBACK to
ON.
Use the SET FLUSH command to control display buffering.
Set FLUSH to
OFF to enable display buffering. If you enable buffering, messages bound for the screen may not appear until the script completes. Please note that setting
FLUSH to
OFF will offer better performance.
Set FLUSH to
ON to disable display buffering. If you disable buffering, messages bound for the screen appear immediately.
Use the SET HEADING variable to specify if Advanced Server should display column headings for
SELECT statements.
The SET HEADSEP command sets the new heading separator character used by the
COLUMN HEADING command. The default is '|'.
Use the SET LINESIZE command to specify the width of a line in characters.
Use the SET NEWPAGE command to specify how many blank lines are printed after a page break.
Use the SET NULL command to specify a string that is displayed to the user when a
NULL column value is displayed in the output buffer.
Use the SET PAGESIZE command to specify the number of printed lines that fit on a page.
Use the line_count parameter to specify the number of lines per page.
The SET SQLCASE command specifies if SQL statements transmitted to the server should be converted to upper or lower case.
Specify UPPER to convert the command text to uppercase.
Specify LOWER to convert the command text to lowercase.
Specify MIXED to leave the case of SQL commands unchanged. The default is
MIXED.
The SET PAUSE command is most useful when included in a script; the command displays a prompt and waits for the user to press
Return.
If SET PAUSE is
ON, the message
Hit ENTER to continue… will be displayed before each command is executed.
Use the SET SPACE command to specify the number of spaces to display between columns:
Use SET SQLPROMPT to set a value for a user-interactive prompt:
Use the SET TERMOUT command to specify if command output should be displayed onscreen.
The SET TIMING command specifies if Advanced Server should display the execution time for each SQL statement after it is executed.
Use the SET TRIMSPOOL command to remove trailing spaces from each line in the output file specified by the
SPOOL command.
Use the SHOW command to display current parameter values.
The SPOOL command sends output from the display to a file.
Use the output_file parameter to specify a path name for the output file.
Use the START command to run an EDB*Plus script file;
START is an alias for
@ command.
The UNDEFINE command erases a user variable created by the
DEFINE command.
Use the variable_
name parameter to specify the name of a variable or variables.
The WHENEVER SQLERROR command provides error handling for SQL errors or PL/SQL block errors. The syntax is:
Include the CONTINUE clause to instruct EDB*Plus to perform the specified action before continuing.
Include the COMMIT clause to instruct EDB*Plus to
COMMIT the current transaction before exiting or continuing.
Include the ROLLBACK clause to instruct EDB*Plus to
ROLLBACK the current transaction before exiting or continuing.
Include the NONE clause to instruct EDB*Plus to continue without committing or rolling back the transaction.
Include the EXIT clause to instruct EDB*Plus to perform the specified action and exit if it encounters an error.