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
.
This example shows connectivity for a multi-node cluster (one primary node and two secondary nodes) setup. The given multi-host connectstring
syntax is used to establish a connection with the active primary database server. In this case, using CONNECT
command, the connection is established with the primary database node on host 192.168.22.24
at port 5444
.
DEFINE
The DEFINE
command creates or replaces the value of a user variable (also called a substitution variable).
If you give the DEFINE
command 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
, which you can optionally enclose in single or double quotation marks. Quotation marks must be used if text
contains space characters.
This example defines two variables, dept
and name
:
Note
The variable EDB
is read from the login.sql
file located in the edbplus
subdirectory of the EDB Postgres Advanced Server home directory.
DEL
DEL
deletes one or more lines from the SQL buffer.
The parameters specify the lines to delete from the SQL buffer. Two parameters specify the start and end of a range of lines to delete. Giving the DEL
command without parameters deletes the current line.
n
n
is an integer representing the nth line.
n m
n
and m
are integers, where m
is greater than n
representing the nth through the mth lines.
*
Current line.
LAST
Last line.
This example deletes the fifth and sixth lines, which contain columns sal
and comm
, respectively, from the SELECT
command in the SQL buffer.
DESCRIBE
The DESCRIBE
command displays:
- A list of columns, column data types, and column lengths for a table or view
- A list of parameters for a procedure or function
- A list of procedures and functions and their respective parameters for a package
The DESCRIBE
command also displays the structure of the database object referred to by a synonym. The syntax is:
schema
Name of the schema containing the object to describe.
object
Name of the table, view, procedure, function, or package to display or the synonym of an object.
DISCONNECT
The DISCONNECT
command closes the current database connection but doesn't end the EDB*Plus session.
EDIT
The EDIT
command invokes an external editor to edit the contents of an operating system file or the SQL buffer.
filename[.ext ]
filename
is the name of the file to open with an external editor. ext
is the filename extension. If the extension is sql
, then you can omit it. (EDIT
assumes a .sql
extension on filenames that are specified with no extension.) If you omit the filename
parameter from the EDIT
command, the contents of the SQL buffer are brought into the editor.
EXECUTE
The EXECUTE
command executes an SPL procedure from EDB*Plus.
spl_procedure
The name of the SPL procedure to execute.
parameters
Comma-delimited list of parameters. If there are no parameters, then you can optionally specify a pair of empty parentheses.
EXIT
The EXIT
command ends 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
.
Returns an operating-system-dependent return code indicating successful operation, failure, or warning for SUCCESS
, FAILURE
, and WARNING
, respectively. The default is SUCCESS
.
value
An integer value returned as the return code.
variable
A variable created with the DEFINE
command whose value is returned as the return code.
COMMIT | ROLLBACK
If you specify COMMIT
, uncommitted updates are committed upon exit. If you specify ROLLBACK
, uncommitted updates are rolled back upon exit. The default is COMMIT
.
GET
The GET
command loads the contents of the given file to the SQL buffer.
filename[.ext ]
filename
is the name of the file to load into the SQL buffer. ext
is the filename extension. If the extension is sql
, then you can omit it. GET
assumes a .sql
extension on filenames that are specified with no extension.
LIST | NOLIST
If you specify LIST
, the contents of the SQL buffer are displayed after the file is loaded. If you specify NOLIST
, no listing is displayed. The default is LIST
.
HELP
The HELP
command gets an index of topics or help on a specific topic. The question mark (?)
is synonymous with specifying HELP
.
INDEX
Displays an index of available topics.
topic
The name of a specific topic, such as an EDB*Plus command, for which you want help.
HOST
The HOST
command executes an operating system command from EDB*Plus.
os_command
The operating system command to execute. If you don't provide an operating system command, EDB*Plus pauses and opens a new shell prompt. When the shell exits, EDB*Plus resumes execution.
INPUT
The INPUT
command adds a line of text to the SQL buffer after the current line.
This sequence of INPUT
commands constructs a SELECT
command:
LIST
LIST
displays the contents of the SQL buffer.
The buffer doesn't include a history of the EDB*Plus commands.
n
n
represents the buffer line number.
n m
n m
displays a list of lines between n
and m
.
n *
n *
displays a list of lines that range between line n
and the current line.
n L[AST]
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
* n
displays a list of lines that range from the current line through line n
.
* L[AST]
* L[AST]
displays a list of lines that range from the current line through the last line.
L[AST]
L[AST]
displays the last line.
PASSWORD
Use the PASSWORD
command to change your database password.
You must have privileges to use the PASSWORD
command to change another user's password. This example uses the PASSWORD
command to change the password for a user named acctg:
PAUSE
The PAUSE
command displays a message and waits for the user to press ENTER
.
optional_text
specifies the text to display to the user. If you omit optional_text
, EDB Postgres Advanced Server displays two blank lines. If you double quote the optional_text
string, the quotes are included in the output.
PROMPT
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.
QUIT
The QUIT
command ends the session and returns control to the operating system. QUIT
is a synonym for EXIT
.
The default value is QUIT SUCCESS COMMIT
.
REMARK
Use REMARK
to include comments in a script.
You can also use the following convention to include a comment:
SAVE
Use the SAVE
command to write the SQL buffer to an operating system file.
file_name
file_name
specifies the name of the file (including the path) where the buffer contents are written. If you don't provide a file extension, .sql
is appended to the end of the filename.
CREATE
Include the CREATE
keyword to create a file. A file is created only if a file with the specified name doesn't already exist. This is the default.
REPLACE
Include the REPLACE
keyword to overwrite an existing file.
APPEND
Include the APPEND
keyword to append the contents of the SQL buffer to the end of the specified file.
This example saves the contents of the SQL buffer to a file named example.sql
, located in the temp
directory:
SET
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.
SET AUTOCOMMIT`
Use the SET AUTOCOMMIT
command to specify commit behavior for EDB Postgres Advanced Server transactions.
EDB*Plus always automatically commits DDL statements.
ON
Specify ON
to turn on AUTOCOMMIT
behavior.
OFF
Specify OFF
to turn off AUTOCOMMIT
behavior.
IMMEDIATE
IMMEDIATE
has the same effect as ON
.
statement_count
Include a value for statement_count
to issue a commit after the specified count of successful SQL statements.
SET COLUMN SEPARATOR
Use the SET COLUMN SEPARATOR
command to specify the text to display between columns.
The default value of column_separator
is a single space.
SET ECHO
Use the SET ECHO
command to specify to display SQL and EDB*Plus script statements onscreen as they execute.
The default value is OFF
.
SET FEEDBACK
The SET FEEDBACK
command controls the display of interactive information after a SQL statement executes.
row_threshold
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
.
SET FLUSH
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 might not appear until the script completes. Setting FLUSH
to OFF
offers better performance.
Set FLUSH
to ON
to disable display buffering. If you disable buffering, messages bound for the screen appear immediately.
SET HEADING
Use the SET HEADING
variable to specify whether to display column headings for SELECT
statements.
SET HEADSEP
The SET HEADSEP
command sets the new heading separator character used by the COLUMN HEADING
command. The default is '|'
.
SET LINESIZE
Use the SET LINESIZE
command to specify the width of a line in characters.
width_of_line
The default value of width_of_line
is 132
.
SET NEWPAGE
Use the SET NEWPAGE
command to specify how many blank lines to print after a page break.
lines_per_page
The default value of lines_per_page
is 1
.
SET NULL
Use the SET NULL
command to specify a string to display when a NULL
column value is displayed in the output buffer.
SET PAGESIZE
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.
SET SQLCASE
The SET SQLCASE
command specifies whether to convert SQL statements transmitted to the server to upper or lower case.
UPPER
Specify UPPER
to convert the command text to upper case.
LOWER
Specify LOWER
to convert the command text to lower case.
MIXED
Specify MIXED
to leave the case of SQL commands unchanged. The default is MIXED
.
SET PAUSE
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 …
appears before each command executes.
SET SPACE
Use the SET SPACE
command to specify the number of spaces to display between columns.
SET SQLPROMPT
Use SET SQLPROMPT
to set a value for a user-interactive prompt.
By default, SQLPROMPT
is set to "SQL> "
SET TERMOUT
Use the SET TERMOUT
command to specify to display command output.
SET TIMING`
The SET TIMING
command specifies whether to display the execution time for each SQL statement after it executes.
SET TRIMSPOOL`
Use the SET TRIMSPOOL
command to remove trailing spaces from each line in the output file specified by the SPOOL
command.
The default value is OFF
.
SET VERIFY
Specifies whether to display both the old and new values of a SQL statement when a substitution variable is encountered.
SHOW
Use the SHOW
command to display current parameter values.
Display the current parameter settings by including the ALL
keyword:
Or display a specific parameter setting by including the parameter_name
in the SHOW
command:
SPOOL
The SPOOL
command sends output from the display to a file.
Use the output_file
parameter to specify a pathname for the output file.
START
Use the START
command to run an EDB*Plus script file. START
is an alias for the @
command.
Specify the name of a script file in the script_file
parameter.
UNDEFINE
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.
WHENEVER SQLERROR
The WHENEVER SQLERROR
command provides error handling for SQL errors or PL/SQL block errors. The syntax is:
If EDB Postgres Advanced Server encounters an error while executing a SQL command or PL/SQL block, EDB*Plus performs the action specified in the WHENEVER SQLERROR
command:
Include the
CONTINUE
clause to perform the specified action before continuing.Include the
COMMIT
clause to commit the current transaction before exiting or continuing.Include the
ROLLBACK
clause to roll back the current transaction before exiting or continuing.Include the
NONE
clause to continue without committing or rolling back the transaction.Include the
EXIT
clause to perform the specified action and exit in case of an error.
Use the following options to specify a status code that EDB*Plus returns before exiting:
EDB*Plus supports substitution variables but doesn't support bind variables.