Postgres: Difference between revisions
| Line 11: | Line 11: | ||
DROP TABLE <TABLE>; | DROP TABLE <TABLE>; | ||
SELECT * FROM <DB>; | SELECT * FROM <DB>; | ||
GRANT ALL PRIVILEDGES ON "<DB>" TO <USER>; | |||
dropdb -h <HOSTNAME> -U <User> <DB> | dropdb -h <HOSTNAME> -U <User> <DB> | ||
Revision as of 09:02, 16 April 2022
Operation
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
<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 <DB>;
GRANT ALL PRIVILEDGES ON "<DB>" TO <USER>;
dropdb -h <HOSTNAME> -U <User> <DB>
createdb -h <HOSTNAME> -U <User> <DB>