Reduce magento database size

Sometime we may face the problem of huge database size even after all product is deleted. Run the following code in the sql, Sometime we may get error so try to run code one by one. And enable cache for folder only not for database during installation. Source :