Postgres: Difference between revisions
| (17 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
==Operation== | ==Operation== | ||
psql -h <HOSTNAME> -U <USER> [<DB>] | psql -h <HOSTNAME> -U <USER> [<DB>] | ||
psql <DB> <USER> | psql <DB> <USER> | ||
\l // show databases | \l // show databases | ||
\c <DB> // connect to DB | \c <DB> // connect to DB | ||
\d <TABLE> // show schema of table !!! SQL case sensitive, DB to be enclosed in " otherwise no case sensitiveness | |||
\dt // show tables | \dt // show tables | ||
<SQL>; | \du // list users | ||
\q // exit | |||
<SQL>; // e.g. | |||
CREATE DATABASE "<DB>"; // !!! SQL case sensitive, DB to be enclosed in " otherwise no case sensitiveness, semicolon needed | |||
DROP TABLE <TABLE>; | |||
SELECT * FROM <TABLE>; | |||
GRANT ALL PRIVILEDGES ON DATABASE "<DB>" TO <USER>; | |||
dropdb -h <HOSTNAME> -U <User> <DB> | dropdb -h <HOSTNAME> -U <User> <DB> | ||
createdb -h <HOSTNAME> -U <User> <DB> | createdb -h <HOSTNAME> -U <User> <DB> | ||
==Installation== | |||
* [[EDTLaptop1#Postgres|EDT Windows HP Elitebook]] | |||
Latest revision as of 17:11, 26 April 2022
Operation[edit]
psql -h <HOSTNAME> -U <USER> [<DB>]
psql <DB> <USER>
\l // show databases
\c <DB> // connect to DB
\d <TABLE> // show schema of table !!! SQL case sensitive, DB to be enclosed in " otherwise no case sensitiveness
\dt // show tables
\du // list users
\q // exit
<SQL>; // e.g.
CREATE DATABASE "<DB>"; // !!! SQL case sensitive, DB to be enclosed in " otherwise no case sensitiveness, semicolon needed
DROP TABLE <TABLE>;
SELECT * FROM
; GRANT ALL PRIVILEDGES ON DATABASE "<DB>" TO <USER>; dropdb -h <HOSTNAME> -U <User> <DB> createdb -h <HOSTNAME> -U <User> <DB>