HiveBrain v1.2.0
Get Started
← Back to all entries
debugMinor

db2 database alias not listed via list database directory but still unable to create that database

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
directorycreatestillbutunabledb2databaseviathatlisted

Problem

I am trying to create a database by logging on to the linux server on which the db2 server is installed, as the instance owner

db2 => list database directory

 System Database Directory

 Number of entries in the directory = 1

Database 1 entry:

 Database alias                       = SAMPLE
 Database name                        = SAMPLE
 Local database directory             = /home/mylogin/sqllib
 Database release level               = f.00
 Comment                              =
 Directory entry type                 = Indirect
 Catalog database partition number    = 0
 Alternate server hostname            =
 Alternate server port number         =

db2 => create database testdb2
SQL1005N  The database alias "TESTDB2" already exists in either the local 
database directory or system database directory.
    db2 => list database directory on /home/mylogin/sqllib

 Local Database Directory on /home/mylogin/sqllib

 Number of entries in the directory = 1

Database 1 entry:

 Database alias                       = SAMPLE
 Database name                        = SAMPLE
 Database directory                   = SQL00001
 Database release level               = f.00
 Comment                              =
 Directory entry type                 = Home
 Catalog database partition number    = 0
 Database member number               = 0
db2 => quit


I also checked if there are any other instances that exist other than mine, but there aren't.

DB20000I  The QUIT command completed successfully.
-bash-4.1$ db2ilist
mylogin


While the alias testdb2 is not listed by list database directory , db2 claims that this alias already exists in either the system database directory or the local database directory.

If this is true, how do I get the equivalent of list database directory that lists testdb2 as well?

Solution

There is a database in the default database path which has the same name and not cataloged. You must first catalog it, then drop it. After that you can create a database with that name. If you can't do it or don't want to drop it, then use ON PATH and DBPATH parameters of the CREATE DB statement and provide a different directory than the default directory.

Here is a workaround for your problem:

db2 catalog database testdb2 as oldtestdb
db2 create database testdb2x
db2 uncatalog database testdb2x
db2 catalog database testdb2x as testdb2


Now you have your database testdb2

Code Snippets

db2 catalog database testdb2 as oldtestdb
db2 create database testdb2x
db2 uncatalog database testdb2x
db2 catalog database testdb2x as testdb2

Context

StackExchange Database Administrators Q#50020, answer score: 2

Revisions (0)

No revisions yet.