4

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?

2 Answers 2

2

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

1

db2 list db directory is for the system level directory. There is also db2 list db directory on <path> which lists any databases on that particular path.

Wondering if you have tried to uncatalog or catalog it first? You could see if cataloging it allows you to drop it.

Worse case you may need to locate the spot on disk with the database and remove it manually (as long as it isn't cataloged).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.