Skip to content

Instantly share code, notes, and snippets.

@corbanb
Last active June 11, 2016 19:11
Show Gist options
  • Select an option

  • Save corbanb/84c28da42c5a04cf4bdf to your computer and use it in GitHub Desktop.

Select an option

Save corbanb/84c28da42c5a04cf4bdf to your computer and use it in GitHub Desktop.
PostgreSQL Useful commands

psql commands

Export to CSV

$ psql postgres://user:pass@localhost:1337/dbname -o 'file.csv' -F , --no-align -c 'SELECT * FROM column ORDER BY created_at ASC;'

Arrays

UPDATE "Jobs" SET "subscribers" = array_replace("subscribers", '[email protected]', '[email protected]') WHERE "deletedAt" IS NULL AND '[email protected]' = ANY ("subscribers")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment