Postgres: Difference between revisions
| Line 11: | Line 11: | ||
CREATE DATABASE "<DB>"; // !!! SQL case sensitive, DB to be enclosed in " otherwise no case sensitiveness, semicolon needed | CREATE DATABASE "<DB>"; // !!! SQL case sensitive, DB to be enclosed in " otherwise no case sensitiveness, semicolon needed | ||
DROP TABLE <TABLE>; | DROP TABLE <TABLE>; | ||
SELECT * FROM < | SELECT * FROM <TABLE>; | ||
GRANT ALL PRIVILEDGES ON DATABASE "<DB>" TO <USER>; | GRANT ALL PRIVILEDGES ON DATABASE "<DB>" TO <USER>; | ||
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>