opencart 在数据库删除用户、订单、商品等信息的方法

有时候遇到这种情况,需要清空会员、商品、订单等数据。 如果在后台一条一条删除,就显得很慢了。如何快速删除数据?当然是直接操作数据库了。但是有的表关联比较多,可能会错误的删除表。这里我把sql贴出来,方便新手参考。操作数据库之前一定要记住备份,备份,备份(重要的事情说三遍)

一、删除会员SQL

TRUNCATE TABLE oc_customer;
TRUNCATE TABLE oc_customer_activity;
TRUNCATE TABLE oc_customer_affiliate;
TRUNCATE TABLE oc_customer_affiliate_report;
TRUNCATE TABLE oc_customer_approval;
TRUNCATE TABLE oc_customer_history;
TRUNCATE TABLE oc_customer_ip;
TRUNCATE TABLE oc_customer_login;
TRUNCATE TABLE oc_customer_online;
TRUNCATE TABLE oc_customer_reward;
TRUNCATE TABLE oc_customer_search;
TRUNCATE TABLE oc_customer_transaction;
TRUNCATE TABLE oc_customer_wishlist;
TRUNCATE TABLE oc_address;

二、删除订单SQL

TRUNCATE TABLE oc_order;
TRUNCATE TABLE oc_order_custom_field;
TRUNCATE TABLE oc_order_history;
TRUNCATE TABLE oc_order_option;
TRUNCATE TABLE oc_order_product;
TRUNCATE TABLE oc_order_recurring;
TRUNCATE TABLE oc_order_recurring_transaction;
TRUNCATE TABLE oc_order_total;
TRUNCATE TABLE oc_order_voucher;
TRUNCATE TABLE oc_cart;

三、删除商品SQL

TRUNCATE TABLE oc_coupon_product;
TRUNCATE TABLE oc_product;
TRUNCATE TABLE oc_product_attribute;
TRUNCATE TABLE oc_product_description;
TRUNCATE TABLE oc_product_discount;
TRUNCATE TABLE oc_product_filter;
TRUNCATE TABLE oc_product_image;
TRUNCATE TABLE oc_product_option;
TRUNCATE TABLE oc_product_option_value;
TRUNCATE TABLE oc_product_recurring;
TRUNCATE TABLE oc_product_related;
TRUNCATE TABLE oc_product_reward;
TRUNCATE TABLE oc_product_special;
TRUNCATE TABLE oc_product_to_category;
TRUNCATE TABLE oc_product_to_download;
TRUNCATE TABLE oc_product_to_layout;
TRUNCATE TABLE oc_product_to_store;
QQ截图20181205103953.jpg

再次提醒,执行以上sql之前,一定要先备份数据库。以免造成不必要的损失