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

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

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

How to rename table in PostgreSQL

In this article, we will see how to rename table in PostgreSQL. We can rename a table by using alter command.

Syntax to rename table in PostgreSQL:

ALTER TABLE table_name RENAME TO new_table_name;

Examples:
Continue reading How to rename table in PostgreSQL

How to rename column in PostgreSQL

In this article, we will see how to rename a column in PostgreSQL with examples using ALTER TABLE command with RENAME parameter.

To rename a column of a table, you use the ALTER TABLE statement with RENAME COLUMN clause as follows:

Syntax to PostgreSQL Rename column:

ALTER TABLE table_name RENAME COLUMN column_name TO new_column_name;

Continue reading How to rename column in PostgreSQL

How to rename PostgreSQL Table

In this article, we will see how to rename PostgreSQL Table. ALTER TABLE is the command used to rename table in PostgreSQL Server. To execute ALTER TABLE, we must be owner of table or superuser or granted alter table permission on the table.

PostgreSQL Rename Table Syntax:

ALTER TABLE name RENAME TO new_name

Continue reading How to rename PostgreSQL Table

How to rename PostgreSQL User

In this article, We will see how to rename PostgreSQL User. ALTER ROLE is used for PostgreSQL rename User.

Permissions Required are:

  • Database superusers can rename any role.
  • Roles having CREATEROLE privilege can rename non-superuser roles.
  • The current session user cannot be renamed.

Syntax to Rename PostgreSQL User:

ALTER ROLE name RENAME TO new_name

Continue reading How to rename PostgreSQL User

How to rename PostgreSQL database

In this article, we will see How to rename PostgreSQL database. ALTER DATABASE command is used to change the name of database in PostgreSQL Server. Only the database owner or a superuser can rename a database and non-superuser owners must also have the CREATEDB privilege.

ALTER DATABASE Syntax:

ALTER DATABASE database_name RENAME TO new_database_name [ [ WITH ] option [ ... ] ]

Continue reading How to rename PostgreSQL database