DB2 database directory shows DB that does not exist

Andrew Niefer picture Andrew Niefer · Oct 10, 2013 · Viewed 10.9k times · Source

I have an old test database showing when I run db2 list database directory

Database 8 entry:

 Database alias                       = TEST_AN
 Database name                        = TEST_AN
 Local database directory             = /home/users/db2inst
 Database release level               = d.00
 Comment                              =
 Directory entry type                 = Indirect
 Catalog database partition number    = 0
 Alternate server hostname            =
 Alternate server port number         =

But it is not there when I run db2 list database directory on /home/users/db2inst

I can't connect to it:

> db2 connect to TEST_AN
SQL1013N  The database alias name or database name "TEST_AN" could not be 
found.  SQLSTATE=42705

or drop it:

> db2 drop db TEST_AN
SQL1013N  The database alias name or database name "TEST_AN  " could not be 
found.  SQLSTATE=42705

And I can't create a new DB using that name:

> db2 create database TEST_AN
SQL1005N  The database alias "TEST_AN" already exists in either the local 
database directory or system database directory.

Does anyone know what the problem is, how can I get rid of this db that does and does not exist?

Answer

Joachim Isaksson picture Joachim Isaksson · Oct 10, 2013

It would seem your local catalog is out of sync.

You may want to try UNCATALOG DATABASE TEST_AN, which will manually remove the database registration from the local catalog.