Re: Dropped database still shows in the database list.

From: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "'girish R G peetle *EXTERN*'" <giri(dot)anamika0(at)gmail(dot)com>, pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Dropped database still shows in the database list.
Date: 2015-05-22 08:05:41
Message-ID: A737B7A37273E048B164557ADEF4A58B366147D2@ntex2010i.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

girish R G peetle wrote:
> Dropped database 'RestoreDB' is still being listed in pg_database.
> Any idea why this behavior is seen ? Also I don't see any open connections to this database.
> pg_stat_activity has no rows for this database.
>
> * postgres=# create database ResotreDB;
> CREATE DATABASE

This is a typo, and it should be "RestoreDB", right?
When reporting problems of this kind, please always copy and paste from the screen,
rather than typing it by hand. Often typos cause problems like that, and additional
typos in the report make it harder to figure out the cause of the problem.

> * postgres=# select oid, * from pg_database where datname like 'RestoreDB';
> oid | datname | datdba | encoding | datcollate | datctype | datistemplate | datallowconn |
> datconnlimit | datlastsysoid | datfrozenxid | datminmxid | dattablespace | datacl
> --------+-----------+--------+----------+-------------+-------------+---------------+--------------+--
> ------------+---------------+--------------+------------+---------------+--------
> 177109 | RestoreDB | 10 | 6 | en_US.UTF-8 | en_US.UTF-8 | f | t |
> -1 | 12891 | 1800 | 1 | 1663 |
> (1 row)

But this is a different database!

The database you created above (modulo typo) is "restoredb", all in lower case,
because PostgreSQL folds unquoted strings to lower case.

So now, if you run "SELECT datname FROM pg_database;", you should have both
"restoredb" and "RestoreDB" in there. Is that so?

If you want mixed case, use double quotes:
CREATE DATABASE "RestoreDB";
That statement should fail because the database already exists.

> * postgres=# drop database RestoreDB;
> DROP DATABASE

You dropped "restoredb".

> * postgres=# select oid, * from pg_database where datname like 'RestoreDB';
> oid | datname | datdba | encoding | datcollate | datctype | datistemplate | datallowconn |
> datconnlimit | datlastsysoid | datfrozenxid | datminmxid | dattablespace | datacl
> --------+-----------+--------+----------+-------------+-------------+---------------+--------------+--
> ------------+---------------+--------------+------------+---------------+--------
> 177109 | RestoreDB | 10 | 6 | en_US.UTF-8 | en_US.UTF-8 | f | t |
> -1 | 12891 | 1800 | 1 | 1663 |

... and "RestoreDB" is still around.

I urge you to only use lower case for all database objects in PostgreSQL.
It will save you a lot of trouble.

Yours,
Laurenz Albe

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message David G. Johnston 2015-05-22 08:06:18 Re: Dropped database still shows in the database list.
Previous Message girish R G peetle 2015-05-22 06:50:06 Dropped database still shows in the database list.