A very simple docker-compose of PostgreSQL.
This repo is only used on my Raspberry Pi 3 with Ubuntu 18.04 (ARM64).
foo@bar:~$ docker run --rm -it postgres:alpine psql --version
psql (PostgreSQL) 13.0
foo@bar:~$ docker run --rm -it postgres:alpine psql --help
psql is the PostgreSQL interactive terminal.
Usage:
psql [OPTION]... [DBNAME [USERNAME]]
General options:
-c, --command=COMMAND run only single command (SQL or internal) and exit
-d, --dbname=DBNAME database name to connect to (default: "root")
-f, --file=FILENAME execute commands from file, then exit
-l, --list list available databases, then exit
-v, --set=, --variable=NAME=VALUE
set psql variable NAME to VALUE
(e.g., -v ON_ERROR_STOP=1)
-V, --version output version information, then exit
-X, --no-psqlrc do not read startup file (~/.psqlrc)
-1 ("one"), --single-transaction
execute as a single transaction (if non-interactive)
-?, --help[=options] show this help, then exit
--help=commands list backslash commands, then exit
--help=variables list special variables, then exit
Input and output options:
-a, --echo-all echo all input from script
-b, --echo-errors echo failed commands
-e, --echo-queries echo commands sent to server
-E, --echo-hidden display queries that internal commands generate
-L, --log-file=FILENAME send session log to file
-n, --no-readline disable enhanced command line editing (readline)
-o, --output=FILENAME send query results to file (or |pipe)
-q, --quiet run quietly (no messages, only query output)
-s, --single-step single-step mode (confirm each query)
-S, --single-line single-line mode (end of line terminates SQL command)
Output format options:
-A, --no-align unaligned table output mode
--csv CSV (Comma-Separated Values) table output mode
-F, --field-separator=STRING
field separator for unaligned output (default: "|")
-H, --html HTML table output mode
-P, --pset=VAR[=ARG] set printing option VAR to ARG (see \pset command)
-R, --record-separator=STRING
record separator for unaligned output (default: newline)
-t, --tuples-only print rows only
-T, --table-attr=TEXT set HTML table tag attributes (e.g., width, border)
-x, --expanded turn on expanded table output
-z, --field-separator-zero
set field separator for unaligned output to zero byte
-0, --record-separator-zero
set record separator for unaligned output to zero byte
Connection options:
-h, --host=HOSTNAME database server host or socket directory (default: "local socket")
-p, --port=PORT database server port (default: "5432")
-U, --username=USERNAME database user name (default: "root")
-w, --no-password never prompt for password
-W, --password force password prompt (should happen automatically)
For more information, type "\?" (for internal commands) or "\help" (for SQL
commands) from within psql, or consult the psql section in the PostgreSQL
documentation.
Report bugs to <pgsql-bugs@lists.postgresql.org>.
PostgreSQL home page: <https://www.postgresql.org/>
foo@bar:~$ docker run --rm -it postgres:alpine psql --host <host> --username <username> <database_name>
Password for user user:
psql (13.0)
Type "help" for help.
user_db=# help
You are using psql, the command-line interface to PostgreSQL.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
user_db=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+-------+----------+------------+------------+-------------------
postgres | user | UTF8 | en_US.utf8 | en_US.utf8 |
template0 | user | UTF8 | en_US.utf8 | en_US.utf8 | =c/user +
| | | | | user=CTc/user
template1 | user | UTF8 | en_US.utf8 | en_US.utf8 | =c/user +
| | | | | user=CTc/user
user_db | user | UTF8 | en_US.utf8 | en_US.utf8 |
(4 rows)
user_db=# \h
Available help:
ABORT ALTER TEXT SEARCH TEMPLATE CREATE PUBLICATION DROP FUNCTION IMPORT FOREIGN SCHEMA
ALTER AGGREGATE ALTER TRIGGER CREATE ROLE DROP GROUP INSERT
ALTER COLLATION ALTER TYPE CREATE RULE DROP INDEX LISTEN
ALTER CONVERSION ALTER USER CREATE SCHEMA DROP LANGUAGE LOAD
ALTER DATABASE ALTER USER MAPPING CREATE SEQUENCE DROP MATERIALIZED VIEW LOCK
ALTER DEFAULT PRIVILEGES ALTER VIEW CREATE SERVER DROP OPERATOR MOVE
ALTER DOMAIN ANALYZE CREATE STATISTICS DROP OPERATOR CLASS NOTIFY
ALTER EVENT TRIGGER BEGIN CREATE SUBSCRIPTION DROP OPERATOR FAMILY PREPARE
ALTER EXTENSION CALL CREATE TABLE DROP OWNED PREPARE TRANSACTION
ALTER FOREIGN DATA WRAPPER CHECKPOINT CREATE TABLE AS DROP POLICY REASSIGN OWNED
ALTER FOREIGN TABLE CLOSE CREATE TABLESPACE DROP PROCEDURE REFRESH MATERIALIZED VIEW
ALTER FUNCTION CLUSTER CREATE TEXT SEARCH CONFIGURATION DROP PUBLICATION REINDEX
ALTER GROUP COMMENT CREATE TEXT SEARCH DICTIONARY DROP ROLE RELEASE SAVEPOINT
ALTER INDEX COMMIT CREATE TEXT SEARCH PARSER DROP ROUTINE RESET
ALTER LANGUAGE COMMIT PREPARED CREATE TEXT SEARCH TEMPLATE DROP RULE REVOKE
ALTER LARGE OBJECT COPY CREATE TRANSFORM DROP SCHEMA ROLLBACK
ALTER MATERIALIZED VIEW CREATE ACCESS METHOD CREATE TRIGGER DROP SEQUENCE ROLLBACK PREPARED
ALTER OPERATOR CREATE AGGREGATE CREATE TYPE DROP SERVER ROLLBACK TO SAVEPOINT
ALTER OPERATOR CLASS CREATE CAST CREATE USER DROP STATISTICS SAVEPOINT
ALTER OPERATOR FAMILY CREATE COLLATION CREATE USER MAPPING DROP SUBSCRIPTION SECURITY LABEL
ALTER POLICY CREATE CONVERSION CREATE VIEW DROP TABLE SELECT
ALTER PROCEDURE CREATE DATABASE DEALLOCATE DROP TABLESPACE SELECT INTO
ALTER PUBLICATION CREATE DOMAIN DECLARE DROP TEXT SEARCH CONFIGURATION SET
ALTER ROLE CREATE EVENT TRIGGER DELETE DROP TEXT SEARCH DICTIONARY SET CONSTRAINTS
ALTER ROUTINE CREATE EXTENSION DISCARD DROP TEXT SEARCH PARSER SET ROLE
ALTER RULE CREATE FOREIGN DATA WRAPPER DO DROP TEXT SEARCH TEMPLATE SET SESSION AUTHORIZATION
ALTER SCHEMA CREATE FOREIGN TABLE DROP ACCESS METHOD DROP TRANSFORM SET TRANSACTION
ALTER SEQUENCE CREATE FUNCTION DROP AGGREGATE DROP TRIGGER SHOW
ALTER SERVER CREATE GROUP DROP CAST DROP TYPE START TRANSACTION
ALTER STATISTICS CREATE INDEX DROP COLLATION DROP USER TABLE
ALTER SUBSCRIPTION CREATE LANGUAGE DROP CONVERSION DROP USER MAPPING TRUNCATE
ALTER SYSTEM CREATE MATERIALIZED VIEW DROP DATABASE DROP VIEW UNLISTEN
ALTER TABLE CREATE OPERATOR DROP DOMAIN END UPDATE
ALTER TABLESPACE CREATE OPERATOR CLASS DROP EVENT TRIGGER EXECUTE VACUUM
ALTER TEXT SEARCH CONFIGURATION CREATE OPERATOR FAMILY DROP EXTENSION EXPLAIN VALUES
ALTER TEXT SEARCH DICTIONARY CREATE POLICY DROP FOREIGN DATA WRAPPER FETCH WITH
ALTER TEXT SEARCH PARSER CREATE PROCEDURE DROP FOREIGN TABLE GRANT
user_db=# \?
General
\copyright show PostgreSQL usage and distribution terms
\crosstabview [COLUMNS] execute query and display results in crosstab
\errverbose show most recent error message at maximum verbosity
\g [(OPTIONS)] [FILE] execute query (and send results to file or |pipe);
\g with no arguments is equivalent to a semicolon
\gdesc describe result of query, without executing it
\gexec execute query, then execute each value in its result
\gset [PREFIX] execute query and store results in psql variables
\gx [(OPTIONS)] [FILE] as \g, but forces expanded output mode
\q quit psql
\watch [SEC] execute query every SEC seconds
Help
\? [commands] show help on backslash commands
\? options show help on psql command-line options
\? variables show help on special variables
\h [NAME] help on syntax of SQL commands, * for all commands
Query Buffer
\e [FILE] [LINE] edit the query buffer (or file) with external editor
\ef [FUNCNAME [LINE]] edit function definition with external editor
\ev [VIEWNAME [LINE]] edit view definition with external editor
\p show the contents of the query buffer
\r reset (clear) the query buffer
\s [FILE] display history or save it to file
\w FILE write query buffer to file
Input/Output
\copy ... perform SQL COPY with data stream to the client host
\echo [-n] [STRING] write string to standard output (-n for no newline)
\i FILE execute commands from file
\ir FILE as \i, but relative to location of current script
\o [FILE] send all query results to file or |pipe
\qecho [-n] [STRING] write string to \o output stream (-n for no newline)
\warn [-n] [STRING] write string to standard error (-n for no newline)
Conditional
\if EXPR begin conditional block
\elif EXPR alternative within current conditional block
\else final alternative within current conditional block
\endif end conditional block
Informational
(options: S = show system objects, + = additional detail)
\d[S+] list tables, views, and sequences
\d[S+] NAME describe table, view, sequence, or index
\da[S] [PATTERN] list aggregates
\dA[+] [PATTERN] list access methods
\dAc[+] [AMPTRN [TYPEPTRN]] list operator classes
\dAf[+] [AMPTRN [TYPEPTRN]] list operator families
\dAo[+] [AMPTRN [OPFPTRN]] list operators of operator families
\dAp [AMPTRN [OPFPTRN]] list support functions of operator families
\db[+] [PATTERN] list tablespaces
\dc[S+] [PATTERN] list conversions
\dC[+] [PATTERN] list casts
\dd[S] [PATTERN] show object descriptions not displayed elsewhere
\dD[S+] [PATTERN] list domains
\ddp [PATTERN] list default privileges
\dE[S+] [PATTERN] list foreign tables
\det[+] [PATTERN] list foreign tables
\des[+] [PATTERN] list foreign servers
\deu[+] [PATTERN] list user mappings
\dew[+] [PATTERN] list foreign-data wrappers
\df[anptw][S+] [PATRN] list [only agg/normal/procedures/trigger/window] functions
\dF[+] [PATTERN] list text search configurations
\dFd[+] [PATTERN] list text search dictionaries
\dFp[+] [PATTERN] list text search parsers
\dFt[+] [PATTERN] list text search templates
\dg[S+] [PATTERN] list roles
\di[S+] [PATTERN] list indexes
\dl list large objects, same as \lo_list
\dL[S+] [PATTERN] list procedural languages
\dm[S+] [PATTERN] list materialized views
\dn[S+] [PATTERN] list schemas
\do[S] [PATTERN] list operators
\dO[S+] [PATTERN] list collations
\dp [PATTERN] list table, view, and sequence access privileges
\dP[itn+] [PATTERN] list [only index/table] partitioned relations [n=nested]
\drds [PATRN1 [PATRN2]] list per-database role settings
\dRp[+] [PATTERN] list replication publications
\dRs[+] [PATTERN] list replication subscriptions
\ds[S+] [PATTERN] list sequences
\dt[S+] [PATTERN] list tables
\dT[S+] [PATTERN] list data types
\du[S+] [PATTERN] list roles
\dv[S+] [PATTERN] list views
\dx[+] [PATTERN] list extensions
\dy [PATTERN] list event triggers
\l[+] [PATTERN] list databases
\sf[+] FUNCNAME show a function's definition
\sv[+] VIEWNAME show a view's definition
\z [PATTERN] same as \dp
Formatting
\a toggle between unaligned and aligned output mode
\C [STRING] set table title, or unset if none
\f [STRING] show or set field separator for unaligned query output
\H toggle HTML output mode (currently off)
\pset [NAME [VALUE]] set table output option
(border|columns|csv_fieldsep|expanded|fieldsep|
fieldsep_zero|footer|format|linestyle|null|
numericlocale|pager|pager_min_lines|recordsep|
recordsep_zero|tableattr|title|tuples_only|
unicode_border_linestyle|unicode_column_linestyle|
unicode_header_linestyle)
\t [on|off] show only rows (currently off)
\T [STRING] set HTML <table> tag attributes, or unset if none
\x [on|off|auto] toggle expanded output (currently off)
Connection
\c[onnect] {[DBNAME|- USER|- HOST|- PORT|-] | conninfo}
connect to new database (currently "user_db")
\conninfo display information about current connection
\encoding [ENCODING] show or set client encoding
\password [USERNAME] securely change the password for a user
Operating System
\cd [DIR] change the current working directory
\setenv NAME [VALUE] set or unset environment variable
\timing [on|off] toggle timing of commands (currently off)
\! [COMMAND] execute command in shell or start interactive shell
Variables
\prompt [TEXT] NAME prompt user to set internal variable
\set [NAME [VALUE]] set internal variable, or list all if no parameters
\unset NAME unset (delete) internal variable
Large Objects
\lo_export LOBOID FILE
\lo_import FILE [COMMENT]
\lo_list
\lo_unlink LOBOID large object operations