MySQL Query: How to Delete all WooCommerce Orders

Use this MySQL query to delete all woocommerce orders at once from the MySQL command line. This can be useful if you want to delete all orders on your staging site and then import all orders again from the live site to make the staging site up to date before pushing it to the live site.

DELETE FROM wpstg4_woocommerce_order_itemmeta;
DELETE FROM wpstg4_woocommerce_order_items;
DELETE FROM wpstg4_comments WHERE comment_type = 'order_note';
DELETE FROM wpstg4_postmeta WHERE post_id IN ( SELECT ID FROM wpstg4_posts WHERE post_type = 'shop_order' );
DELETE FROM wpstg4_posts WHERE post_type = 'shop_order';