Skip to content

Instantly share code, notes, and snippets.

@joostvanveen
Created November 3, 2017 10:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joostvanveen/9dd27e91e7098ee72343448480e68203 to your computer and use it in GitHub Desktop.
Save joostvanveen/9dd27e91e7098ee72343448480e68203 to your computer and use it in GitHub Desktop.
Truncate all orders from Magento 2
SET FOREIGN_KEY_CHECKS = 0;
-- TRUNCATE ORDERS
TRUNCATE TABLE `PREFIX_gift_message`;
TRUNCATE TABLE `PREFIX_quote`;
TRUNCATE TABLE `PREFIX_quote_address`;
TRUNCATE TABLE `PREFIX_quote_address_item`;
TRUNCATE TABLE `PREFIX_quote_id_mask`;
TRUNCATE TABLE `PREFIX_quote_item`;
TRUNCATE TABLE `PREFIX_quote_item_option`;
TRUNCATE TABLE `PREFIX_quote_payment`;
TRUNCATE TABLE `PREFIX_quote_shipping_rate`;
TRUNCATE TABLE `PREFIX_reporting_orders`;
TRUNCATE TABLE `PREFIX_sales_bestsellers_aggregated_daily`;
TRUNCATE TABLE `PREFIX_sales_bestsellers_aggregated_monthly`;
TRUNCATE TABLE `PREFIX_sales_bestsellers_aggregated_yearly`;
TRUNCATE TABLE `PREFIX_sales_creditmemo`;
TRUNCATE TABLE `PREFIX_sales_creditmemo_comment`;
TRUNCATE TABLE `PREFIX_sales_creditmemo_grid`;
TRUNCATE TABLE `PREFIX_sales_creditmemo_item`;
TRUNCATE TABLE `PREFIX_sales_invoice`;
TRUNCATE TABLE `PREFIX_sales_invoiced_aggregated`;
TRUNCATE TABLE `PREFIX_sales_invoiced_aggregated_order`;
TRUNCATE TABLE `PREFIX_sales_invoice_comment`;
TRUNCATE TABLE `PREFIX_sales_invoice_grid`;
TRUNCATE TABLE `PREFIX_sales_invoice_item`;
TRUNCATE TABLE `PREFIX_sales_order`;
TRUNCATE TABLE `PREFIX_sales_order_address`;
TRUNCATE TABLE `PREFIX_sales_order_aggregated_created`;
TRUNCATE TABLE `PREFIX_sales_order_aggregated_updated`;
TRUNCATE TABLE `PREFIX_sales_order_grid`;
TRUNCATE TABLE `PREFIX_sales_order_item`;
TRUNCATE TABLE `PREFIX_sales_order_payment`;
TRUNCATE TABLE `PREFIX_sales_order_status_history`;
TRUNCATE TABLE `PREFIX_sales_order_tax`;
TRUNCATE TABLE `PREFIX_sales_order_tax_item`;
TRUNCATE TABLE `PREFIX_sales_payment_transaction`;
TRUNCATE TABLE `PREFIX_sales_refunded_aggregated`;
TRUNCATE TABLE `PREFIX_sales_refunded_aggregated_order`;
TRUNCATE TABLE `PREFIX_sales_shipment`;
TRUNCATE TABLE `PREFIX_sales_shipment_comment`;
TRUNCATE TABLE `PREFIX_sales_shipment_grid`;
TRUNCATE TABLE `PREFIX_sales_shipment_item`;
TRUNCATE TABLE `PREFIX_sales_shipment_track`;
TRUNCATE TABLE `PREFIX_sales_shipping_aggregated`;
TRUNCATE TABLE `PREFIX_sales_shipping_aggregated_order`;
TRUNCATE TABLE `PREFIX_tax_order_aggregated_created`;
TRUNCATE TABLE `PREFIX_tax_order_aggregated_updated`;
SET FOREIGN_KEY_CHECKS = 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment