Using Psql On The Command Line To Examine PostgreSQL Databases

Posted by Weston Ganger on April 15, 2015

I keep finding myself looking for this information so I have started compiled a cheatsheet of psql commands. Enjoy.

$ psql postgres

\l #show all databases
\c databaseName #switch databases
\dt #show all tables in current database
\d+ tableName #show schema of tableName in current database
\du #show all users
create database databaseName; #create database
drop database databaseName; #drop database
\q #quit

ALTER USER myuser WITH SUPERUSER; #make user a superuser
ALTER USER myuser WITH NOSUPERUSER; #remove superuser from user

Posted in Linux and Tagged with psql postgres database 

Need help on your next project or application?

I specialize in Ruby-on-Rails, AngularJS, Javascript, Bootstrap, and Hybrid Mobile Apps with Cordova & Ionic.

Contact Me

Recommended Posts