SQL1031N if some data files go missing
Sometimes, people inadvertently delete containers belonging to a DB2 database directly from the file system instead of dropping the database. In such cases, it can be frustrating to try and restore the database from a backup because the restore command fails as does the attempt to first try and drop the database.
The following might help...
$ db2 drop db cogcondb
SQL1031N The database directory cannot be found on the indicated file system.
SQLSTATE=58031
That could mean that the entry for the db is present in the system db directory but it could not be found in the local db directory (which will be in DFTDBPATH by default). So, let us uncatalog it from the system db directory and manually remove any leftover files for this db (including its logs) from the local db directories.
Go to each local db directory (such as C: , D: etc on Windows and /home/db2inst1, etc on Unix. Any directory that contains NODE0000 is two levels under a db directory).
Run the command "db2 list db directory on c:" or "db2 list db directory on /home/db2inst1" for example and make a note of what database is present under which home directory.
Next, issue a db2 list db directory command which will list all the databases that the system as such is aware of. If you find that there are databases which got listed on local but which are not present in the system directory, you can first catalog them (by issuing a catalog database on /home/db2inst1 for example). Cataloguing will create an entry for the database in the system directory after which you can drop it with the usual DROP database command.
The following might help...
$ db2 drop db cogcondb
SQL1031N The database directory cannot be found on the indicated file system.
SQLSTATE=58031
That could mean that the entry for the db is present in the system db directory but it could not be found in the local db directory (which will be in DFTDBPATH by default). So, let us uncatalog it from the system db directory and manually remove any leftover files for this db (including its logs) from the local db directories.
Go to each local db directory (such as C: , D: etc on Windows and /home/db2inst1, etc on Unix. Any directory that contains NODE0000 is two levels under a db directory).
Run the command "db2 list db directory on c:" or "db2 list db directory on /home/db2inst1" for example and make a note of what database is present under which home directory.
Next, issue a db2 list db directory command which will list all the databases that the system as such is aware of. If you find that there are databases which got listed on local but which are not present in the system directory, you can first catalog them (by issuing a catalog database
Labels: sql1031n db2 list drop database directory restore local system

0 Comments:
Post a Comment
<< Home