0

Did anyone know how to remove the Sample data from Database using Mysql script, I know we can remove using CLI, But i need a script to remove in Database.

1

This is what I have used to clean up test customers & orders:

-- Magento EE 2.1.1 
SET FOREIGN_KEY_CHECKS = 0;

-- Clearing all orders
TRUNCATE sales_bestsellers_aggregated_daily;
TRUNCATE sales_bestsellers_aggregated_monthly;
TRUNCATE sales_bestsellers_aggregated_yearly;

TRUNCATE sales_creditmemo;
TRUNCATE sales_creditmemo_comment;
TRUNCATE sales_creditmemo_grid;
TRUNCATE sales_creditmemo_item;
TRUNCATE sales_invoice;
TRUNCATE sales_invoice_comment;
TRUNCATE sales_invoice_grid;
TRUNCATE sales_invoice_item;
TRUNCATE sales_invoiced_aggregated;
TRUNCATE sales_invoiced_aggregated_order;
TRUNCATE sales_order;
TRUNCATE sales_order_address;
TRUNCATE sales_order_aggregated_created;
TRUNCATE sales_order_aggregated_updated;
TRUNCATE sales_order_grid;
TRUNCATE sales_order_item;
TRUNCATE sales_order_payment;
-- TRUNCATE sales_order_status;
TRUNCATE sales_order_status_history;
-- TRUNCATE sales_order_status_label;
-- TRUNCATE sales_order_status_state;
TRUNCATE sales_order_tax;
TRUNCATE sales_order_tax_item;
TRUNCATE sales_payment_transaction;
TRUNCATE sales_refunded_aggregated;
TRUNCATE sales_refunded_aggregated_order;
-- TRUNCATE sales_sequence_meta;
-- TRUNCATE sales_sequence_profile;
TRUNCATE sales_shipment;
TRUNCATE sales_shipment_comment;
TRUNCATE sales_shipment_grid;
TRUNCATE sales_shipment_item;
TRUNCATE sales_shipment_track;
TRUNCATE sales_shipping_aggregated;
TRUNCATE sales_shipping_aggregated_order;

TRUNCATE tax_order_aggregated_created;
TRUNCATE tax_order_aggregated_updated;
TRUNCATE reporting_orders;

-- EE Only
TRUNCATE magento_customercustomattributes_sales_flat_order;
TRUNCATE magento_customercustomattributes_sales_flat_order_address;
TRUNCATE magento_sales_creditmemo_grid_archive;
TRUNCATE magento_sales_invoice_grid_archive;
TRUNCATE magento_sales_order_grid_archive;
TRUNCATE magento_sales_shipment_grid_archive;


-- Clearing all cart items
TRUNCATE quote;
TRUNCATE quote_address;
TRUNCATE quote_address_item;
TRUNCATE quote_id_mask;
TRUNCATE quote_item;
TRUNCATE quote_item_option;
TRUNCATE quote_payment;
TRUNCATE quote_shipping_rate;

-- EE Only
TRUNCATE magento_customercustomattributes_sales_flat_quote;
TRUNCATE magento_customercustomattributes_sales_flat_quote_address;


-- Clearing all customers
TRUNCATE customer_address_entity;
TRUNCATE customer_address_entity_datetime;
TRUNCATE customer_address_entity_decimal;
TRUNCATE customer_address_entity_int;
TRUNCATE customer_address_entity_text;
TRUNCATE customer_address_entity_varchar;
TRUNCATE customer_dummy_cl;
-- TRUNCATE customer_eav_attribute;
-- TRUNCATE customer_eav_attribute_website;
TRUNCATE customer_entity;
TRUNCATE customer_entity_datetime;
TRUNCATE customer_entity_decimal;
TRUNCATE customer_entity_int;
TRUNCATE customer_entity_text;
TRUNCATE customer_entity_varchar;
-- TRUNCATE customer_form_attribute;
TRUNCATE customer_grid_flat;
-- TRUNCATE customer_group;
TRUNCATE customer_log;
TRUNCATE customer_visitor;
TRUNCATE persistent_session;

TRUNCATE wishlist;
TRUNCATE wishlist_item;
TRUNCATE wishlist_item_option;

-- reviews (be careful...)

TRUNCATE gift_message;
TRUNCATE review;
TRUNCATE review_detail;
-- TRUNCATE review_entity;
TRUNCATE review_entity_summary;
-- TRUNCATE review_status;
TRUNCATE review_store;

-- Clearing log tables
TRUNCATE magento_logging_event;
TRUNCATE magento_logging_event_changes;

SET FOREIGN_KEY_CHECKS = 1;
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy