Postgres: Difference between revisions

From Wiki RB4
Line 12: Line 12:
     DROP TABLE <TABLE>;
     DROP TABLE <TABLE>;
     SELECT * FROM <DB>;  
     SELECT * FROM <DB>;  
   GRANT ALL PRIVILEDGES ON "<DB>" TO <USER>;
   GRANT ALL PRIVILEDGES ON DATABASE "<DB>" TO <USER>;


  dropdb -h <HOSTNAME> -U <User> <DB>
  dropdb -h <HOSTNAME> -U <User> <DB>

Revision as of 09:15, 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
  \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 <DB>; 
  GRANT ALL PRIVILEDGES ON DATABASE "<DB>" TO <USER>;
dropdb -h <HOSTNAME> -U <User> <DB>
createdb -h <HOSTNAME> -U <User> <DB>

Installation