Created
July 2, 2014 15:51
-
-
Save wwgist/0c38675bc1a2aae7b131 to your computer and use it in GitHub Desktop.
PSQL: usage hints
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PostgreSQL hints | |
psql [option...] [dbname [username]] | |
-U > username (default=unix_user) VEVAR=PGUSER | |
-W > password | |
-w > no-password | |
-d > dbname VEVAR=PGDATABASE | |
-h > hostname (default=unix_socket/localhost) VEVAR=PGHOST | |
-p > port (default=default) | |
-c > command | |
-html > html output | |
-o > file-to-output | |
# from command line: | |
connectdb: psql dbname | |
clquery: psql -U username -d mydatabase -c 'SELECT * FROM mytable' | |
clcreatedb: createdb 'database name' | |
cldropdb: dropdb 'database name' | |
cldblist: psql --list | |
# from psql console (meta-commands): | |
\c [dbname][username][hostname][port] | |
\list db list | |
\dt tables list (current db) | |
\i [full path and file name with extension] import file.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment