Also have a look our article for removing log entries and shrinking your DB
First thing - make sure you have a backup of your DB, do not run this code unless you are sure what you are doing! It will delete content from your Umbraco database.
By default Umbraco keeps old versions of your content, so you DB can get quite large if you are making lot of changes.
If you need to save space in your Umbraco DB, you can delete the old versions and delete any unpublished content.
You will need to do this via Microsoft SQL Server Management Studio (SSMS), which if you do not have installed can be found here. You will also need to open up the firewall to allow you to connect to the SQL Server, this is shown here.
Follow these steps to remove your old content...
DELETE FROM cmsPropertyData WHERE
versionId NOT IN (SELECT versionId FROM cmsDocument WHERE published = 1 OR newest = 1) AND
contentNodeId IN (SELECT DISTINCT nodeID FROM cmsDocument)
DELETE FROM cmsPreviewXml WHERE
versionId NOT IN (SELECT versionId FROM cmsDocument WHERE published = 1 OR newest = 1) AND
nodeId IN (SELECT DISTINCT nodeID FROM cmsDocument)
DELETE FROM cmsContentVersion WHERE
versionId NOT IN (SELECT versionId FROM cmsDocument WHERE published = 1 OR newest = 1) AND
ContentId IN (SELECT DISTINCT nodeID FROM cmsDocument)
DELETE FROM cmsDocument WHERE
versionId NOT IN (SELECT versionId FROM cmsDocument WHERE published = 1 OR newest = 1) AND
nodeId IN (SELECT DISTINCT nodeID FROM cmsDocument)
That's it - you have now removed old content from the DB - if you are running Umbraco 7, you may also need to clear it's cache - you can do this by going to the URL on your site..
http://yoursite.com/Umbraco/dialogs/republish.aspx?xml=true
2025 © Nutty About Hosting. All Rights Reserved. Privacy Policy | Terms and Conditions | GDPR | Partners | Green Hosting
Follow us on Twitter to receive updates regarding network issues, discounts and more. All prices exclude VAT.