How to remove the full history of a page using SQL

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

In some cases, you may want to delete the whole history of a page. Feature request (CONFSERVER-27701 - Ability to administer number of page versions for a given space or page) for more options when administering a page's history has been implemented in Confluence 7.16.0.

Solution

Resolution

If you are unsure how to deal with the database, contact your DBA. Make sure to have the database backed up completely before going further. These SQL commands were tested in some environments and they worked as intended, however it might not work in specific cases and newer versions of confluence as new constraints as changes may be done to confluence database structure. As such, a database backup is mandatory in case something goes wrong and you need to revert.

Please note this queries will only work when:

  • The title of the page has not changed across versions.

  • There is no other page with the same title in your Confluence instance.

The process to remove a page's history is

Always back up your data before making any database modifications. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.

  1. Shutdown Confluence.

  2. Backup your database in case you need to restore the data.

  3. Run the following SQL queries on your Confluence database:

    1 2 3 4 5 6 DELETE FROM extrnlnks WHERE contentid in (SELECT contentid FROM content WHERE title = 'Page Title' AND prevver IS NOT NULL); DELETE FROM bodycontent WHERE contentid in (SELECT contentid FROM content WHERE title = 'Page Title' AND prevver IS NOT NULL); DELETE FROM contentproperties where contentid in (SELECT contentid FROM content WHERE title = 'Remove my History' AND prevver IS NOT NULL); DELETE FROM usercontent_relation where targetcontentid in (SELECT contentid FROM content WHERE title = 'Remove my History' AND prevver IS NOT NULL); DELETE FROM content WHERE title = 'Page Title' AND prevver IS NOT NULL; UPDATE content SET version = 1 WHERE title = 'Page Title';
  4. Start Confluence.

  5. Rebuild the search index.

  6. Go to Confluence Admin > Cache Statistics and click on Flush all at the bottom of the page.

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.