|
Launch EnterpriseDB PSQL from the command line.
|
Allow a user to launch EnterpriseDB PSQL and connect to a specific database by giving
valid credentials, database name, username and password, as described below:
edb-psql dbname userid password
| edb-psql edb enterprisedb --Connect to the edb database as user enterprisedb
|
| DESC or DESCRIBE for getting the definition of database objects.
| The EnterpriseDB PSQL DESCRIBE/DESC command returns the
definitions of tables, views, procedures, functions and packages in a particular database.
| For example to view the definition of our sample "dept" table, you would do
something as follows:
edb=# DESCRIBE dept;
Table "public.dept"
Column | Type | Modifiers
--------+--------------+-----------
deptno | numeric(2,0) | not null
dname | varchar2(14) |
loc | varchar2(13) |
Indexes:
"dept_pk" PRIMARY KEY
"dept_dname_uq" UNIQUE
In order to view the definition of our sample "list_emp" procedure, you would do the following:
edb=# DESCRIBE list_emp;
List of procedures
Schema | Name | Argument data types
--------+----------+---------------------
public | list_emp |
(1 row)
|
|
edit
|
Opens the last query in the editor.
| edb=# SELECT empno,ename from emp;
empno | ename
-------+--------
7369 | SMITH
7499 | ALLEN
7521 | WARD
7566 | JONES
7654 | MARTIN
7698 | BLAKE
7782 | CLARK
7788 | SCOTT
7839 | KING
7844 | TURNER
7876 | ADAMS
7900 | JAMES
7902 | FORD
7934 | MILLER
(14 rows)
edb=# edit
|
|
L or List for query listing
|
Support for L command which enables listing last query in the buffer in EnterpriseDB PSQL.
| Suppose we run the following query, and then subsequently use L, it would list
the last query as shown below:
edb=# SELECT empno, ename FROM emp
edb-# WHERE deptno = 10;
empno | ename
-------+--------
7782 | CLARK
7839 | KING
7934 | MILLER
(3 rows)
edb=# L
SELECT empno, ename FROM emp
WHERE deptno = 10; |
|
R or Run for query listing and execution
|
Support for R command in EnterpriseDB PSQL for listing and executing the last query in the buffer.
| Suppose we ran the following query previously in EnterpriseDB PSQL,
then used R, it would re run the query as shown below:
SELECT empno, ename FROM emp
WHERE deptno = 10;
edb=# R
empno | ename
-------+--------
7782 | CLARK
7839 | KING
7934 | MILLER
(3 rows) |
|
Save [filename]
|
This command saves the last query in the specified filename.
| Suppose we ran the following query previously in EnterpriseDB PSQL,
then used Save [filename], it
would save the query in the specified filename as shown below:
edb=# SELECT empno,ename from emp;
empno | ename
-------+--------
7369 | SMITH
7499 | ALLEN
7521 | WARD
7566 | JONES
7654 | MARTIN
7698 | BLAKE
7782 | CLARK
7788 | SCOTT
7839 | KING
7844 | TURNER
7876 | ADAMS
7900 | JAMES
7902 | FORD
7934 | MILLER
(14 rows)
edb=# save "C:\SQL File.txt" |
|
\set autocommit [on/off]
|
Sets the autocommit on or off.
| edb=# insert into test values (1);
INSERT 0 1
edb=# select * from test;
i
---
1
(1 row)
edb=# set autocommit on;
|
|
Spool [filename]
|
This command logs all the command errors and the corresponding output to the specified file and shows the status of spooling.
| The use of this command is shown below:
edb=# Spool "C:\log.txt"
edb=# CREATE TABLE test(int i);
ERROR: type "i" does not exist
edb=# CREATE TABLE test (i integer);
CREATE TABLE
|
|
Exit or Quit to terminate EnterpriseDB PSQL
|
Allow the use of exit or quit command to terminate a EnterpriseDB PSQL session.
| The following example exists from EnterpriseDB PSQL
and takes you back to your normal shell/command prompt.
edb=# exit
[sarah@isb-sarah work]#
|
|
support for "rem[ark]" for comments.
|
Whenever the statement beginning with REM or
REMARK is encountered, EnterpriseDB PSQL treats
all remaining characters on that line as comments.
Hence using REM or
REMARK will have the same effect as "--", a comment.
| The following query depicts this usage:
REM this statement fetches employees
REM belonging to department 10
SELECT empno, ename FROM emp
WHERE deptno = 10;
empno | ename
-------+--------
7782 | CLARK
7839 | KING
7934 | MILLER
(3 rows)
|
|
\dA [ pattern ]
|
Lists all available synonyms. If pattern is specified, only synonyms whose names match the pattern are shown.
| \dA
|