1
0
mirror of https://github.com/onkelbeh/cheatsheets.git synced 2025-10-16 23:47:47 +02:00
cheatsheets/postgresql.md
2018-12-06 15:15:40 -07:00

488 B

title, category
title category
PostgreSQL Databases

Replace anything within <placeholder> accordingly

Console

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

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