Postgres: Difference between revisions

From Wiki RB4
Line 7: Line 7:
   \dt // show tables
   \dt // show tables
   <SQL>;
   <SQL>;
   CREATE DATABASE <DB>; // !!! case sensitive and semicolon
   CREATE DATABASE "<DB>"; // !!! SQL case sensitive, DB to be enclosed in " otherwise no case sensitiveness, semicolon needed
  dropdb -h <HOSTNAME> -U <User> <DB>
  dropdb -h <HOSTNAME> -U <User> <DB>
  createdb -h <HOSTNAME> -U <User> <DB>
  createdb -h <HOSTNAME> -U <User> <DB>

Revision as of 09:41, 1 October 2021

Operation

psql -h <HOSTNAME> -U <USER> [<DB>]
psql <DB> <USER>
  \l // show databases
  \c <DB> // connect to DB
  \d <TABLE> // show schema of table
  \dt // show tables
  <SQL>;
  CREATE DATABASE "<DB>"; // !!! SQL case sensitive, DB to be enclosed in " otherwise no case sensitiveness, semicolon needed
dropdb -h <HOSTNAME> -U <User> <DB>
createdb -h <HOSTNAME> -U <User> <DB>