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 create PostgreSQL User with superuser privileges

In this article, we will see how to create PostgreSQL User with superuser privileges by two ways.

Create PostgreSQL User/Role with superuser privileges by using either of following methods:
1. Create User/Role first then assign superuser privilege.
2. Create User/Role with superuser privileges.

Continue reading How to create PostgreSQL User with superuser privileges

How to set permanent schema path to user in PostgreSQL

In this article, we will see how to set permanent schema path to user in PostgreSQL with examples. We can set it by using ALTER ROLE command.

Syntax to set permanent schema path to user in PostgreSQL:
Continue reading How to set permanent schema path to user 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 rename role or user in PostgreSQL

In this article, we will see how to rename role or user in PostgreSQL.

The alter role/user statement is used to rename role or user in PostgreSQL.

Syntax:

ALTER ROLE/USER ROLE_NAME RENAME TO NEW_NAME;

Continue reading How to rename role or user in PostgreSQL

What is the difference between SESSION_USER and CURRENT_USER in PostgreSQL

In this article, we will see the difference between SESSION_USER and CURRENT_USER in PostgreSQL.

Difference between SESSION_USER and CURRENT_USER in PostgreSQL:
SESSION_USER is the role name of the role that is connected to the database.
Continue reading What is the difference between SESSION_USER and CURRENT_USER in PostgreSQL

How to rename PostgreSQL role name

In this article, we will see how to rename PostgreSQL role name.

The ALTER ROLE statement also allows for a change in the name of the role: the RENAME
clause allows for a role to be substituted by another unique role name.

Syntax to rename PostgreSQL role:
Continue reading How to rename PostgreSQL role name

PostgreSQL ERROR: role cannot be dropped because some objects depend on it

We are going to see the solution for “PostgreSQL ERROR: role cannot be dropped because some objects depend on it”

ERROR: role "james" cannot be dropped because some objects depend on it DETAIL: owner of database emp 6 objects in database r2schools 1 object in database postgres 3 objects in database newdb 3 objects in database emp

PostgreSQL ERROR:  role cannot be dropped because some objects depend on it

Solution:
Continue reading PostgreSQL ERROR: role cannot be dropped because some objects depend on it