Command summary v41
Use these commands with EDB*Plus.
ACCEPT
The ACCEPT
command displays a prompt and waits for keyboard input. The value from the input is placed in the specified variable.
This example creates a new variable named my_name
, accepts a value of John Smith
, and then displays the value using the DEFINE
command.
APPEND
APPEND
appends the given text to the end of the current line in the SQL buffer.
In this example, a SELECT
command is built in the SQL buffer using the APPEND
command. Two spaces are placed between the APPEND
command and the WHERE
clause to separate dept
and WHERE
by one space in the SQL buffer.
CHANGE
CHANGE
performs a search-and-replace on the current line in the SQL buffer.
If you specify TO/
, the first occurrence of the text FROM
in the current line is changed to text TO
. If you omit TO/
, the first occurrence of the text FROM
in the current line is deleted.
This sequence of commands makes line 3 the current line and then changes the department number in the WHERE
clause from 20 to 30.
CLEAR
The CLEAR
command removes the contents of the SQL buffer, deletes all column definitions set with the COLUMN
command, or clears the screen.
BUFFER | SQL
Clears the SQL buffer.
COLUMNS
Removes column definitions.
SCREEN
Clears the screen. This is the default.
COLUMN
The COLUMN
command controls output formatting. The formatting attributes set by using the COLUMN
command remain in effect only for the current session.
If you specify the COLUMN
command with no other 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 can be followed by one of the following:
- No other options
CLEAR
- Any combination of
FORMAT
,HEADING
,NEW_VALUE
and eitherOFF
orON
column_name
Name of a column in a table to which column formatting options apply. If no other options follow column_name
, then the current column formatting options of column_name
, if any, are displayed.
CLEAR
The CLEAR
option reverts all formatting options to their defaults for column_name
. If you specify the CLEAR
option, it must be the only option specified.
format_spec
Format specification to apply to column_name
. For character columns, format_spec
takes the following format:
n
n
is a positive integer that specifies the column width in characters within which to display the data. Data in excess of n
wraps around with the specified column width.
For numeric columns, format_spec
is made up of the following elements.
Element | Description |
---|---|
$ | Display a leading dollar sign. |
, | Display a comma in the indicated position. |
. | Marks the location of the decimal point. |
0 | Display leading zeros. |
9 | Number of significant digits to display. |
If loss of significant digits occurs due to overflow of the format, then all #s are displayed.
heading_text
Text to use for the column heading of column_name
.
NEW_V[ALUE]
This variable option is valid if specified alone or with other already supported options. A variable specified in the COLUMN
command option is associated with the given column. The variable can contain the data value of a column or expression of a variable in the SQL SELECT
list. You can use it in the SQL script for the rest of the session.
To contain the departmentnumber
value for the deptno
column, you can define a variable using the NEW_VALUE
option:
The NEW_V[ALUE]
variable has the following limitations:
- Column values differ when they're seeded using the
NEW_VALUE
parameter for the "time with time zone" data type. - The
NEW_VALUE
variable prompts for the value if the corresponding column value isNULL
. Oracle treatsNULL
and an empty string the same, while EDB Postgres Advanced Server has a different behavior. Therefore, in EDB*Plus it prompts for the value. - The variable value doesn't show in the
COLUMN
header if you reference theNEW_VALUE
variable in aSELECT
query without an alias.
OFF | ON
If you specify OFF
, formatting options revert to their defaults but are still available in the session. If you specify ON
, the formatting options specified by previous COLUMN
commands for column_name
in the session are reactivated.
This example shows the effect of changing the display width of the job
column:
This example applies a format to the sal
column:
CONNECT
Change the database connection to a different user or connect to a different database. There must be no white space between any of the parameters following the CONNECT
command. The syntax is:
Where:
username
is a database username with which to connect to the database.
password
is the password associated with the specified username. If you don't provide a password, but a password is required for authentication, a search is made for a password file. The search looks 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:
If a password file can't be located or it doesn't have an entry matching the EDB*Plus connection parameters, then EDB*Plus prompts for the password. For more information about password files, see the PostgreSQL core documentation.
!!! Note
When a password isn't required, EDB*Plus doesn't 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.
connectstring
is the database connection string. See Using EDB*Plus for more information about the database connection string.
variable
is a variable defined in the login.sql
file that contains a database connection string. The login.sql
file is in the edbplus
subdirectory of the EDB Postgres Advanced Server home directory.
In this example, the database connection is changed to database edb
on the localhost at port 5445
with username smith
.
In this session, the connection is changed to the username enterprisedb
. The host defaults to the localhost, the port defaults to 5444
(which isn't the same as the port previously used), and the database defaults to edb
.