How to Check Default Current Active Working Schema in PostgreSQL Database Server

Posted on

Introduction

This article will show how to check the default current active working schema in PostgreSQL database Server. As in the title of this article, actually it is very important. Because it will affect any further query executions. If running the query execution in a different schema, the query will produce different output. So, in order to receive the correct response, just check the default current active working schema first. In order to do that, just execute a certain command or query in the PostgreSQL command line.

Check Default Current Active Working Schema in PostgreSQL Database Server

In order to check the default current active working schema in the PostgreSQL database server, just do the following steps :

  1. First of all, access the PostgreSQL command line using a super user or an admin user. The following is the actual process for accessing the PostgreSQL command line :

    C:\Users\Personal>psql -Upostgres -d employee
    Password for user postgres:
    psql (12.2)
    WARNING: Console code page (437) differs from Windows code page (1252)
    8-bit characters might not work correctly. See psql reference
    page "Notes for Windows users" for details.
    Type "help" for help.
    
    employee=#
    
  2. In order to check the default current active working schema, just execute the following command or query pattern :

    show search_path

    Using the above command or query pattern, execute it in the PostgreSQL command line as follows :

    employee=# show search_path;
     search_path
    -------------
     public
    (1 row)
    
    employee=#
    
  3. As in the above output command, the default current active working schema is ‘public’. So, everytime the user logging in to the database ’employee’, it will have the ‘public’ schema as its default current active working schema. Every execution of the command or query will have the ‘public’ schema as the target. In other words, the query or the command will affect the ‘public’ schema as the default current active working schema. So, make sure that the current active working schema is the right one by using the above command or query.

Leave a Reply