Test major Koha Wiki changes or bug fixes here without fear of breaking the production wiki.
For the current Koha Wiki, visit https://wiki.koha-community.org .How to delete all records and keep settings
Delete records while keeping configuration settings
Deletes data from a Koha instance (library) without deleting the configuration, authorized values etc.
Introduction
When to use? If you need to empty the Koha library of all its data without losing configuration settings and authorized values, e.g. borrower types, locations, libraries, media types... This will mostly be needed when preparing for large data operations like importing or migrating data into Koha from other sources, when one or several test runs have to be performed before the final operation can take place.
Please note: This takes place on database level and has to be done carefully! It is recommended to back up the database first!
Steps
In order to remove
- bibliographic records and/or
- items and/or
- authorities and/or
- borrowers and/or
- current user sessions and/or
- zebraqueue
Login to database
sudo su mysql -u root use your_koha_library;
Execute the following commands
SET FOREIGN_KEY_CHECKS=0;
Make sure to set this back from 0 to 1 after truncating all or your particular choice of the tables!
- Biblios and items
TRUNCATE items; TRUNCATE deleteditems; TRUNCATE biblioitems; TRUNCATE biblio; TRUNCATE deletedbiblioitems; TRUNCATE deletedbiblio; TRUNCATE biblio_metadata; TRUNCATE deletedbiblio_metadata;
- Authorities
TRUNCATE auth_header;
- Borrowers
TRUNCATE borrowers; TRUNCATE deletedborrowers;
- Sessions and queue for zebra indexing
TRUNCATE sessions; TRUNCATE zebraqueue;
- Must be done after any of the TRUNCATE commands
SET FOREIGN_KEY_CHECKS=1;
In some cases the TRUNCATE commands e.g. for items and biblioitems have to be carried out more than once to really empty the table. The result can be checked by
select count(*) from table;
e.g.:
select count(*) from biblioitems;
--> result must be 0
Reset Zebra index
zebraidx -c /etc/koha/sites/your_koha_library/zebra-authorities-dom.cfg -g iso2709 -d authorities init zebraidx -c /etc/koha/sites/your_koha_library/zebra-biblios-dom.cfg -g iso2709 -d biblios init