PostgreSQL Error: database is being accessed by other users

In this article, we will the solution for PostgreSQL Error: database is being accessed by other users
Detail: There are 2 other sessions using the database

ERROR  database  is being accessed by other users
Continue reading PostgreSQL Error: database is being accessed by other users

Switch role after connecting to database in PostgreSQL

In this article, we will see how to Switch role after connecting to database in PostgreSQL with examples.

We can switch or change the current use/role as active using set command.
Continue reading Switch role after connecting to database in PostgreSQL

How to find list of active sessions/connections in PostgreSQL database

In this article, we will see how to find list of active sessions/connections in PostgreSQL database.

We can find list of active/inactive sessions/connections by querying against PostgreSQL system view pg_stat_activity.
Continue reading How to find list of active sessions/connections in PostgreSQL database

PostgreSQL pgadmin error Unable to connect to Server

PostgreSQL pgadmin error Unable to connect to Server:

FATAL: Invalid username specified. Please check the Username and retry connection.
The Username should be in format.

PostgreSQL pgadmin error Unable to connect to Server
Continue reading PostgreSQL pgadmin error Unable to connect to Server

How to create copy of existing database in PostgreSQL

In this article, we will see how to create copy of existing database in PostgreSQL.

Postgres allows the use of any existing database on the server as a template when creating a new database.

Syntax to create copy of PostgreSQL Database:
Continue reading How to create copy of existing database in PostgreSQL

psql: error: FATAL: role is not permitted to log in

I have received following error when trying to connect to PostgreSQL server.

psql: error: FATAL: role is not permitted to log in

psql error FATAL role is not permitted to log in
Continue reading psql: error: FATAL: role is not permitted to log in

How to find all conf files location in PostgreSQL

In this article, we will see how to find all conf files location in PostgreSQL.

As a DBA, we must know where config files are located in our file system. Following steps are applied to Linux and Windows Operating Systems.

We cant get the config files location is PostgreSQL by using SHOW command, or by querying pg_settings catalog and by searching in Operating system.

Find all conf files location in PostgreSQL:
Continue reading How to find all conf files location in PostgreSQL

How to find the number of active database connections in PostgreSQL

In this article, we will see how to find the number of active database connections in PostgreSQL. We can find number active connections to entire PostgreSQL server and individual databases using pg_stat_database view.

1. Find the number of active total connections in PostgreSQL Server.
Continue reading How to find the number of active database connections in PostgreSQL

How to create a read-only user in PostgreSQL

If we only grant CONNECT to a database, the user can connect but has no other privileges. We have to grant USAGE on namespaces (schemas) and SELECT on tables and views individually like so:

1. Create User.

create user r2admin with password 'admin@123';

Continue reading How to create a read-only user in PostgreSQL

Set PostgreSQL concurrent connection limit

In this article we are going to set PostgreSQL concurrent connection limit for user. As a administrator, we have to revoke permissions from the user, set the connection limits to user and set unlimited concurrent connection limits.

Set PostgreSQL concurrent connection limit:
In this video, we have the concurrent user connection limit to none,5, and unlimited.

1. Set concurrent connection limit none.

alter user anil connection limit 0;

Continue reading Set PostgreSQL concurrent connection limit