Skip to content

Instantly share code, notes, and snippets.

@erangaeb
Last active February 1, 2016 06:54
Show Gist options
  • Save erangaeb/93d446b67336ebf47245 to your computer and use it in GitHub Desktop.
Save erangaeb/93d446b67336ebf47245 to your computer and use it in GitHub Desktop.
Psql commands
# connect
psql -h <host> -p <port> -U <user>
psql -h dev.localhost -p 15534 -U postgres
# list databases
\list
# connect to database
\connect <databasename>
\connect senz
# select query
select * from employee where name='eranga'
# update query
update employee set name = ‘eranga’ where id=’12';
# list tables
\dt
# view table structure
\d+ <table name>
\d+ employee
# exeucte sql script
psql -Upostgres -d senz -h dev.localhost -f updateSenz.sql -p 15534
# base64 decode
decode('<encoded data>', 'base64')
#base64 encode
encode('<data>', 'base64')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment