10

I'm trying to rename a DB in pgAdmin 4. But I this get error: ERROR: current database cannot be renamed.

What's the process for renaming a database in pgAdmin (the docs are USELESS)? And google can't provide a solution.

  • 2
    Connect to a different database, then run `alter database .. rename to ...` https://www.postgresql.org/docs/current/static/sql-alterdatabase.html –  May 09 '18 at 07:10

3 Answers3

8

Using pgAdmin 4,

1) switch to the dashboard view

2) select the database to be renamed, right-click it and select Disconnect Database

3) Again select the database to be renamed, right-click it and select properties

4) change the name of the database in the Database field -click save

enter image description here

KenBuckley
  • 573
  • 6
  • 13
2

right click on db name and Properties, then change the name and click Saveenter image description here:

Or just click on other db (eg postgres), open query tool and run

alter database "old" rename to "new";
Vao Tsun
  • 47,234
  • 13
  • 100
  • 132
2

You are probably trying to rename the database you are connected to. Switch to a different db and then execute the ALTER command.

Pavan
  • 41
  • 2