Skip to content

Latest commit

 

History

History
25 lines (18 loc) · 507 Bytes

postgresql.md

File metadata and controls

25 lines (18 loc) · 507 Bytes
title category layout
PostgreSQL
Databases
2017/sheet

Console

$ psql #logs in to default database & default user
$ sudo -u <rolename:postgres> psql #logs in with a particular user

Replace anything within <placeholder> accordingly

Commands

  • Show roles: \du
  • Show tables: \dt
  • Show databases: \l
  • Connect to a database: \c <database>
  • Show columns of a table: \d <table> or \d+ <table>
  • Quit: \q

Creating database

 $ createdb databasename