How to delete library data in koha using command line

Sometimes you need to empty the all data (e.g. bibliographic, borrowers, and transaction details)  from your Koha LMS without losing the configuration settings and authorized values, e.g. libraries, item types, patron categories, locations, etc. Let us know how to delete data from Koha instance/library.

Delete koha bibliographic data

NB: I would recommend taking a backup of the database before applying the following commands.

Login as a root user

sudo su

Log into MySQL database

mysql -uroot -p

Enter MySQL root password

use koha_library;

Disable foreign key constraints when you truncate the tables

SET FOREIGN_KEY_CHECKS=0;

Delete all bibliographic details

TRUNCATE items; 
TRUNCATE biblioitems; 
TRUNCATE biblio; 
TRUNCATE deletedbiblioitems;
TRUNCATE deletedbiblio; 
TRUNCATE biblio_metadata;

Delete all transactions 

TRUNCATE old_issues; 
TRUNCATE issues; 

Delete borrowers details

TRUNCATE borrowers; 
TRUNCATE deletedborrowers;

Don't forget to Enable foreign key constraints when you are done

SET FOREIGN_KEY_CHECKS=1;

Reference:- https://wiki.koha-community.org/wiki/How_to_delete_all_records_and_keep_settings#Delete_records_while_keeping_configuration_settings

Post a Comment

0 Comments