Records without items are BAD NEWS! They mislead people searching our library’s catalog to think that they have found exactly what they are looking for when in the real sense, they are seeing something that does not exist. To reduce the frustrations of your library users, this post will attempt to help you delete records without items from your koha catalog in a few easy steps.
- Access your koha server command-line
- Back-up your database
- Log-in to MySQL shell
- Select koha database
- Delete records
- Re-index zebra
- Check for records without items
You will need to access the server on which koha is installed. You can either access it remotely using ssh or physically. Either way, get to the command-line and move to the second step.
Before you touch anything, you need to backup your database! Don’t say I didn’t say!
To backup your databse, issue the command below:
mysqldump -u root -p dbName > backup.sql
Key in your password and press enter.
NB: Replace dbName with the actual name of your database and backup.sql is the name of the file in which you want to store your backup. You can call it any name you want including the file extension as long as it is a text file.
Issue the command below to login to MySQL:
mysql -u root -p
This will request you for a password again.
If you are not sure what the name of your koha database is, issue the command below:
This will list all the databases on your server. If you still can’t identify it, consult whoever installed Koha or use some other techniques out there. You eventually have it, select using the command below:
NB: Replace dbName with the actual name of your database.
DO NOT CONTINUE BEFORE YOU’VE BACKED UP THE DATABSE !
Issue the command below to delete records without items from your koha database:
DELETE FROM biblio WHERE biblio.biblionumber NOT IN (SELECT biblionumber FROM items);
Watch out for errors in the out put otherwise you have just successfully deleted records without items from your koha database.
Now you need to exit the database ASAP. Issue the command below:
To reflect the changes on your database, it must be re-indexed. You can either wait for koha’s scheduled cron-jobs to run or issue the following commands to see results immediately:
sudo rebuild_zebra.pl -a -b -z
The above command should be run in the folder in which koha’s source files are installed precisely, the misc/migration_tools/ folder.
Now you can go ahead to search your catalogue and confirm if the records have actually been removed.
For feedback and corrections, use the comments section below