PerfSpy

Tuesday, November 10, 2015

PostgreSQL Cheat Sheet



Open command line

sudo -u postgres psql


Quit command line

\q

Get the current user

SELECT CURRENT_USER;

List databases

\l

Connect to a database

\c dbname

List tables in a database

\dt

List columns of a table

\d tablename

Export the sql result to a CSV

Copy (Select * From tablename) To '/tmp/result.csv' With CSV;

Limit the sql result

select * from tablename limit 10;

Work with JSONB type

https://www.compose.io/articles/is-postgresql-your-next-json-database/
Posted by perfspy at 11:53:00 PM No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Newer Posts Older Posts Home
Subscribe to: Posts (Atom)

Blog Archive

  • ►  2019 (2)
    • ►  May (1)
    • ►  January (1)
  • ►  2018 (2)
    • ►  February (1)
    • ►  January (1)
  • ►  2017 (26)
    • ►  December (2)
    • ►  November (1)
    • ►  September (1)
    • ►  August (4)
    • ►  July (2)
    • ►  May (7)
    • ►  April (4)
    • ►  March (4)
    • ►  January (1)
  • ►  2016 (26)
    • ►  December (4)
    • ►  August (3)
    • ►  July (6)
    • ►  June (6)
    • ►  May (4)
    • ►  February (3)
  • ▼  2015 (18)
    • ►  December (1)
    • ▼  November (2)
      • PostgreSQL Cheat Sheet
      • We need a better metaphor than technical debt
    • ►  September (2)
    • ►  July (3)
    • ►  June (1)
    • ►  April (2)
    • ►  March (1)
    • ►  February (6)
  • ►  2014 (17)
    • ►  December (2)
    • ►  November (4)
    • ►  August (4)
    • ►  June (3)
    • ►  March (2)
    • ►  February (2)
  • ►  2013 (14)
    • ►  September (6)
    • ►  August (8)
Awesome Inc. theme. Powered by Blogger.