PostgreSQL Meta-Command using psql: Command Information -III

This is in continuation of My last blog about Meta Commands in PostgreSQL. In last blog I have explained what a Meta command and how to list databases. In next few blogs we will explore few of Meta commands. Lets start exploring schemas.

Visit this series of last blog for other command.

The command we will explore here is:
1. \dn
2. CREATE SCHEMA
3. SET SEARCH_PATH

Once we are able to connect to our database using \c, we can use another psql command to proceed further. To list all schemas of the database connected, we can use \dn.

Listing of all schema of the connected database i.e. blogs

Currently there is only one schema i.e. public. This is default schema created by PostgreSQL for us. We can create new schema using CREATE SCHEMA command.

New schema postgresblogs are created using create schema

New schema is created using CREATE SCHEMA. To navigate to the desired schema in psql, we can use SET command which sets the SEARCH_PATH for our session.

Navigating to schema postgresblogs

This we can use psql to connect to a particual database and schema within that database.

We will explore few more commands in next blog.

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.