Saturday, 3 July 2021

PostgreSQL PSQL commands

PSQL is an interactive terminal to work with the PostgreSQL database. It is used to query data from the PostgreSQL database server faster and more effectively.

Connecting to PostgreSQL container via PSQL

psql -h localhost -p Port -U username -d databasename

  • \l: List all databases (or \list).
  • \d: Display all tables, indexes, views, and sequences.
  • \dt: Display all tables.
  • \di: Display all indexes.
  • \dv: Display all views.
  • \ds: Display all sequences.
  • \dT: Display all types.
  • \dS: Display all system tables.
  • \du: Display all users.
  • \?: show all psql commands.
  • \c dbname [username]: Connect to database, with an optional username (or \connect).
  • \h sql-cmd: show syntax on sql command
  • SELECT version();  :  Retrieve the current version of PostgreSQL server
  • \g: execute the last command again
  • \s: display command history
  • \s: filename: Save the command history to a file
  • \i: file: execute psql commands from a file
  • \e: editor
  • \H: switch the output to HTML
  • \a: switch from aligned to the non-aligned column output
  • \q: Exit psql shell


 

No comments:

Can Jackson Deserialize Java Time ZonedDateTime

Yes, but must include JSR310. Thus ZonedDateTime can be deserialized directly from JSON response to POJO field. <dependency> <g...