Summary - Commands for using postgres on heroku's server. See source link for all the commands you can run for postgres on heroku.
heroku pg:psql
this gets you into the database, then just use regular psql commands. be sure to capitalize properly and include semicolon at end of each query.
if you have more than one database, specify the db after the above command
heroku pg:psql dbname
\q
gets you out of the database back to your command line
see the source link for commands like logging, analyzing, pushing and pulling a complete database to your local machine and more.