Forked from joostvanveen/delete_customers_and_orders_from_magento.sql
Created
September 22, 2018 17:39
-
-
Save deniscsz/37952c512a324cba0ef94d1c717c3e98 to your computer and use it in GitHub Desktop.
Delete all customers and orders from Magento 1*
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- This query delelets all customers and orders from your | |
-- Magento 1.* install. Handy, if you have a bloated | |
-- Magento database and you need to do a bit | |
-- of cleaning up for use on a local machine. | |
-- | |
-- Replace PREFIX_ with your current Magento table prefix. | |
-- | |
-- USE AT OWN RISK. ALWAY BACKUP YOUR DATABASE FIRST. | |
-- | |
-- ----------------------------------------- | |
-- delete all customers and customer logs -- | |
-- ----------------------------------------- | |
SET FOREIGN_KEY_CHECKS = 0; | |
TRUNCATE PREFIX_customer_address_entity; | |
TRUNCATE PREFIX_customer_address_entity_datetime; | |
TRUNCATE PREFIX_customer_address_entity_decimal; | |
TRUNCATE PREFIX_customer_address_entity_int; | |
TRUNCATE PREFIX_customer_address_entity_text; | |
TRUNCATE PREFIX_customer_address_entity_varchar; | |
TRUNCATE PREFIX_customer_entity; | |
TRUNCATE PREFIX_customer_entity_datetime; | |
TRUNCATE PREFIX_customer_entity_decimal; | |
TRUNCATE PREFIX_customer_entity_int; | |
TRUNCATE PREFIX_customer_entity_text; | |
TRUNCATE PREFIX_customer_entity_varchar; | |
TRUNCATE PREFIX_log_customer; | |
TRUNCATE PREFIX_log_visitor; | |
TRUNCATE PREFIX_log_visitor_info; | |
ALTER TABLE PREFIX_customer_address_entity AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_customer_address_entity_datetime AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_customer_address_entity_decimal AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_customer_address_entity_int AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_customer_address_entity_text AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_customer_address_entity_varchar AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_customer_entity AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_customer_entity_datetime AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_customer_entity_decimal AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_customer_entity_int AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_customer_entity_text AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_customer_entity_varchar AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_log_customer AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_log_visitor AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_log_visitor_info AUTO_INCREMENT=1; | |
SET FOREIGN_KEY_CHECKS = 1; | |
-- -------------------- | |
-- delete all orders -- | |
-- -------------------- | |
SET FOREIGN_KEY_CHECKS = 0; | |
TRUNCATE PREFIX_sales_flat_creditmemo; | |
TRUNCATE PREFIX_sales_flat_creditmemo_comment; | |
TRUNCATE PREFIX_sales_flat_creditmemo_grid; | |
TRUNCATE PREFIX_sales_flat_creditmemo_item; | |
TRUNCATE PREFIX_sales_flat_invoice; | |
TRUNCATE PREFIX_sales_flat_invoice_comment; | |
TRUNCATE PREFIX_sales_flat_invoice_grid; | |
TRUNCATE PREFIX_sales_flat_invoice_item; | |
TRUNCATE PREFIX_sales_flat_order; | |
TRUNCATE PREFIX_sales_flat_order_address; | |
TRUNCATE PREFIX_sales_flat_order_grid; | |
TRUNCATE PREFIX_sales_flat_order_item; | |
TRUNCATE PREFIX_sales_flat_order_payment; | |
TRUNCATE PREFIX_sales_flat_order_status_history; | |
TRUNCATE PREFIX_sales_flat_quote; | |
TRUNCATE PREFIX_sales_flat_quote_address; | |
TRUNCATE PREFIX_sales_flat_quote_address_item; | |
TRUNCATE PREFIX_sales_flat_quote_item; | |
TRUNCATE PREFIX_sales_flat_quote_item_option; | |
TRUNCATE PREFIX_sales_flat_quote_payment; | |
TRUNCATE PREFIX_sales_flat_quote_shipping_rate; | |
TRUNCATE PREFIX_sales_flat_shipment; | |
TRUNCATE PREFIX_sales_flat_shipment_comment; | |
TRUNCATE PREFIX_sales_flat_shipment_grid; | |
TRUNCATE PREFIX_sales_flat_shipment_item; | |
TRUNCATE PREFIX_sales_flat_shipment_track; | |
TRUNCATE PREFIX_sales_invoiced_aggregated; | |
TRUNCATE PREFIX_sales_invoiced_aggregated_order; | |
TRUNCATE PREFIX_sales_payment_transaction; | |
TRUNCATE PREFIX_sales_order_aggregated_created; | |
TRUNCATE PREFIX_sales_order_tax; | |
TRUNCATE PREFIX_sales_order_tax_item; | |
TRUNCATE PREFIX_sendfriend_log; | |
TRUNCATE PREFIX_tag; | |
TRUNCATE PREFIX_tag_relation; | |
TRUNCATE PREFIX_tag_summary; | |
TRUNCATE PREFIX_wishlist; | |
TRUNCATE PREFIX_log_quote; | |
TRUNCATE PREFIX_report_event; | |
ALTER TABLE PREFIX_sales_flat_creditmemo AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_flat_creditmemo_comment AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_flat_creditmemo_grid AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_flat_creditmemo_item AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_flat_invoice AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_flat_invoice_comment AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_flat_invoice_grid AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_flat_invoice_item AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_flat_order AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_flat_order_address AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_flat_order_grid AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_flat_order_item AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_flat_order_payment AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_flat_order_status_history AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_flat_quote AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_flat_quote_address AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_flat_quote_address_item AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_flat_quote_item AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_flat_quote_item_option AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_flat_quote_payment AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_flat_quote_shipping_rate AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_flat_shipment AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_flat_shipment_comment AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_flat_shipment_grid AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_flat_shipment_item AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_flat_shipment_track AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_invoiced_aggregated AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_invoiced_aggregated_order AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_payment_transaction AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_order_aggregated_created AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_order_tax AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sales_order_tax_item AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_sendfriend_log AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_tag AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_tag_relation AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_tag_summary AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_wishlist AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_log_quote AUTO_INCREMENT=1; | |
ALTER TABLE PREFIX_report_event AUTO_INCREMENT=1; | |
SET FOREIGN_KEY_CHECKS = 1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment