HostOnNet Blog

Working with PostgreSQL psql

Looking for Linux Server Admin or WordPress Expert? We can help.

psql command is used to connect to PostgreSQL database. To login to PostgreSQL database, run

psql -U username-here -W

You will be asked to enter password.

List all databases

To list all databases use command \list or \l

\list

Connect to a database

Before you can use a database, you need to connect to it with

\connect DB-NAME

List all tables in a database

\dt
\dt *.

Or

SELECT table_schema,table_name FROM information_schema.tables ORDER BY table_schema,table_name;

Posted in Database

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.