마 젠토 2 : 고객, 제품, 리뷰 및 주문 테이블을 자르는 방법


34

Magento 2의 모든 테스트 고객, 제품, 리뷰 및 주문을 삭제하기 위해 잘라야 할 테이블 목록이 있습니까? 테스트 후 Clearing Magento 와 비슷한 것을 찾고 있습니다.


주문 삭제에 도움이됩니다. magecomp.com/magento-2-delete-orders.html
Gaurav Jain

@amitshree의 답변에서 모든 쿼리를 사용했습니다. 그러나 일부 테이블에는 여전히 많은 데이터가 있습니다. + --------------------------------------- -------------------- + -------- + | 테이블 | 행 | + ------------------------------------------------- ---------- + -------- + | catalog_product_attribute_cl | 29613 | | catalogrule_product_cl | 31850 | | url_rewrite | 98607 | | sequence_product | 178345 | | targetrule_product_rule_cl | 1944 | | email_catalog | 99064 | | catalog_product_index_price_replica | 395031 | | cataloginventory_stock_status_replica | 56320 | | catalogsearch_fulltext_cl | 14524 | | catalog_product
Hoangnm 2016 년

새로운 질문이 있으면 질문하기 버튼 을 클릭하여 질문하십시오 . 컨텍스트를 제공하는 데 도움이되는 경우이 질문에 대한 링크를 포함하십시오. - 검토에서
Rama Chandran M

답변:


71

[참고] :이 쿼리를 실행하기 전에 데이터베이스 백업을 수행하십시오.

모든 테이블을 살펴보고 테스트 데이터를 지우려면 잘라야 할 다음 테이블 목록을 생각해 냈습니다.

SET FOREIGN_KEY_CHECKS = 0;

주문 테이블 자르기

TRUNCATE TABLE `gift_message`;
TRUNCATE TABLE `quote`;
TRUNCATE TABLE `quote_address`;
TRUNCATE TABLE `quote_address_item`;
TRUNCATE TABLE `quote_id_mask`;
TRUNCATE TABLE `quote_item`;
TRUNCATE TABLE `quote_item_option`;
TRUNCATE TABLE `quote_payment`;
TRUNCATE TABLE `quote_shipping_rate`;
TRUNCATE TABLE `reporting_orders`;
TRUNCATE TABLE `sales_bestsellers_aggregated_daily`;
TRUNCATE TABLE `sales_bestsellers_aggregated_monthly`;
TRUNCATE TABLE `sales_bestsellers_aggregated_yearly`;
TRUNCATE TABLE `sales_creditmemo`;
TRUNCATE TABLE `sales_creditmemo_comment`;
TRUNCATE TABLE `sales_creditmemo_grid`;
TRUNCATE TABLE `sales_creditmemo_item`;
TRUNCATE TABLE `sales_invoice`;
TRUNCATE TABLE `sales_invoiced_aggregated`;
TRUNCATE TABLE `sales_invoiced_aggregated_order`;
TRUNCATE TABLE `sales_invoice_comment`;
TRUNCATE TABLE `sales_invoice_grid`;
TRUNCATE TABLE `sales_invoice_item`;
TRUNCATE TABLE `sales_order`;
TRUNCATE TABLE `sales_order_address`;
TRUNCATE TABLE `sales_order_aggregated_created`;
TRUNCATE TABLE `sales_order_aggregated_updated`;
TRUNCATE TABLE `sales_order_grid`;
TRUNCATE TABLE `sales_order_item`;
TRUNCATE TABLE `sales_order_payment`;
TRUNCATE TABLE `sales_order_status_history`;
TRUNCATE TABLE `sales_order_tax`;
TRUNCATE TABLE `sales_order_tax_item`;
TRUNCATE TABLE `sales_payment_transaction`;
TRUNCATE TABLE `sales_refunded_aggregated`;
TRUNCATE TABLE `sales_refunded_aggregated_order`;
TRUNCATE TABLE `sales_shipment`;
TRUNCATE TABLE `sales_shipment_comment`;
TRUNCATE TABLE `sales_shipment_grid`;
TRUNCATE TABLE `sales_shipment_item`;
TRUNCATE TABLE `sales_shipment_track`;
TRUNCATE TABLE `sales_shipping_aggregated`;
TRUNCATE TABLE `sales_shipping_aggregated_order`;
TRUNCATE TABLE `tax_order_aggregated_created`;
TRUNCATE TABLE `tax_order_aggregated_updated`;

고객 테이블 자르기

TRUNCATE TABLE `customer_address_entity`;
TRUNCATE TABLE `customer_address_entity_datetime`;
TRUNCATE TABLE `customer_address_entity_decimal`;
TRUNCATE TABLE `customer_address_entity_int`;
TRUNCATE TABLE `customer_address_entity_text`;
TRUNCATE TABLE `customer_address_entity_varchar`;
TRUNCATE TABLE `customer_entity`;
TRUNCATE TABLE `customer_entity_datetime`;
TRUNCATE TABLE `customer_entity_decimal`;
TRUNCATE TABLE `customer_entity_int`;
TRUNCATE TABLE `customer_entity_text`;
TRUNCATE TABLE `customer_entity_varchar`;
TRUNCATE TABLE `customer_grid_flat`;
TRUNCATE TABLE `customer_log`;
TRUNCATE TABLE `customer_log`;
TRUNCATE TABLE `customer_visitor`;
TRUNCATE TABLE `persistent_session`;
TRUNCATE TABLE `wishlist`;
TRUNCATE TABLE `wishlist_item`;
TRUNCATE TABLE `wishlist_item_option`;

검토 테이블 자르기

TRUNCATE TABLE `review`;
TRUNCATE TABLE `review_detail`;
TRUNCATE TABLE `review_entity_summary`;
TRUNCATE TABLE `review_store`;

제품 테이블 자르기

TRUNCATE TABLE `cataloginventory_stock_item`;
TRUNCATE TABLE `cataloginventory_stock_status`;
TRUNCATE TABLE `cataloginventory_stock_status_idx`;
TRUNCATE TABLE `cataloginventory_stock_status_tmp`;
TRUNCATE TABLE `catalog_category_product`;
TRUNCATE TABLE `catalog_category_product_index`;
TRUNCATE TABLE `catalog_category_product_index_tmp`;
TRUNCATE TABLE `catalog_compare_item`;
TRUNCATE TABLE `catalog_product_bundle_option`;
TRUNCATE TABLE `catalog_product_bundle_option_value`;
TRUNCATE TABLE `catalog_product_bundle_price_index`;
TRUNCATE TABLE `catalog_product_bundle_selection`;
TRUNCATE TABLE `catalog_product_bundle_selection_price`;
TRUNCATE TABLE `catalog_product_bundle_stock_index`;
TRUNCATE TABLE `catalog_product_entity`;
TRUNCATE TABLE `catalog_product_entity_datetime`;
TRUNCATE TABLE `catalog_product_entity_decimal`;
TRUNCATE TABLE `catalog_product_entity_gallery`;
TRUNCATE TABLE `catalog_product_entity_int`;
TRUNCATE TABLE `catalog_product_entity_media_gallery`;
TRUNCATE TABLE `catalog_product_entity_media_gallery_value`;
TRUNCATE TABLE `catalog_product_entity_media_gallery_value_to_entity`;
TRUNCATE TABLE `catalog_product_entity_media_gallery_value_video`;
TRUNCATE TABLE `catalog_product_entity_text`;
TRUNCATE TABLE `catalog_product_entity_tier_price`;
TRUNCATE TABLE `catalog_product_entity_varchar`;
TRUNCATE TABLE `catalog_product_index_eav`;
TRUNCATE TABLE `catalog_product_index_eav_decimal`;
TRUNCATE TABLE `catalog_product_index_eav_decimal_idx`;
TRUNCATE TABLE `catalog_product_index_eav_decimal_tmp`;
TRUNCATE TABLE `catalog_product_index_eav_idx`;
TRUNCATE TABLE `catalog_product_index_eav_tmp`;
TRUNCATE TABLE `catalog_product_index_price`;
TRUNCATE TABLE `catalog_product_index_price_bundle_idx`;
TRUNCATE TABLE `catalog_product_index_price_bundle_opt_idx`;
TRUNCATE TABLE `catalog_product_index_price_bundle_opt_tmp`;
TRUNCATE TABLE `catalog_product_index_price_bundle_sel_idx`;
TRUNCATE TABLE `catalog_product_index_price_bundle_sel_tmp`;
TRUNCATE TABLE `catalog_product_index_price_bundle_tmp`;
TRUNCATE TABLE `catalog_product_index_price_cfg_opt_agr_idx`;
TRUNCATE TABLE `catalog_product_index_price_cfg_opt_agr_tmp`;
TRUNCATE TABLE `catalog_product_index_price_cfg_opt_idx`;
TRUNCATE TABLE `catalog_product_index_price_cfg_opt_tmp`;
TRUNCATE TABLE `catalog_product_index_price_downlod_idx`;
TRUNCATE TABLE `catalog_product_index_price_downlod_tmp`;
TRUNCATE TABLE `catalog_product_index_price_final_idx`;
TRUNCATE TABLE `catalog_product_index_price_final_tmp`;
TRUNCATE TABLE `catalog_product_index_price_idx`;
TRUNCATE TABLE `catalog_product_index_price_opt_agr_idx`;
TRUNCATE TABLE `catalog_product_index_price_opt_agr_tmp`;
TRUNCATE TABLE `catalog_product_index_price_opt_idx`;
TRUNCATE TABLE `catalog_product_index_price_opt_tmp`;
TRUNCATE TABLE `catalog_product_index_price_tmp`;
TRUNCATE TABLE `catalog_product_index_tier_price`;
TRUNCATE TABLE `catalog_product_index_website`;
TRUNCATE TABLE `catalog_product_link`;
TRUNCATE TABLE `catalog_product_link_attribute_decimal`;
TRUNCATE TABLE `catalog_product_link_attribute_int`;
TRUNCATE TABLE `catalog_product_link_attribute_varchar`;
TRUNCATE TABLE `catalog_product_option`;
TRUNCATE TABLE `catalog_product_option_price`;
TRUNCATE TABLE `catalog_product_option_title`;
TRUNCATE TABLE `catalog_product_option_type_price`;
TRUNCATE TABLE `catalog_product_option_type_title`;
TRUNCATE TABLE `catalog_product_option_type_value`;
TRUNCATE TABLE `catalog_product_relation`;
TRUNCATE TABLE `catalog_product_super_attribute`;
TRUNCATE TABLE `catalog_product_super_attribute_label`;
TRUNCATE TABLE `catalog_product_super_link`;
TRUNCATE TABLE `catalog_product_website`;
TRUNCATE TABLE `catalog_url_rewrite_product_category`;
TRUNCATE TABLE `downloadable_link`;
TRUNCATE TABLE `downloadable_link_price`;
TRUNCATE TABLE `downloadable_link_purchased`;
TRUNCATE TABLE `downloadable_link_purchased_item`;
TRUNCATE TABLE `downloadable_link_title`;
TRUNCATE TABLE `downloadable_sample`;
TRUNCATE TABLE `downloadable_sample_title`;
TRUNCATE TABLE `product_alert_price`;
TRUNCATE TABLE `product_alert_stock`;
TRUNCATE TABLE `report_compared_product_index`;
TRUNCATE TABLE `report_viewed_product_aggregated_daily`;
TRUNCATE TABLE `report_viewed_product_aggregated_monthly`;
TRUNCATE TABLE `report_viewed_product_aggregated_yearly`;
TRUNCATE TABLE `report_viewed_product_index`;


SET FOREIGN_KEY_CHECKS = 1;

1
이 방법으로 테이블을 자른 후 제품을 추가 / 저장하려고 할 때 SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (magento .cataloginventory_stock_item , CONSTRAINT CATINV_STOCK_ITEM_STOCK_ID_CATINV_STOCK_STOCK_ID` FOREIGN KEY ( stock_id) REFERENCES cataloginventory_stock( stock_id) REFER CASS ) 오류가 발생합니다. 그것은 당신을 위해 작동합니까?
Tom

1
@ Tom이 오류에 직면했습니다. cataloginventory_stock테이블을 자르지 않으면 제대로 작동합니다.
amitshree

이것을 시도하지 마십시오. 이 쿼리를 실행 한 후 그룹화 된 제품이 생성되지 않기 때문입니다.
saravanavelu

@saravanavelu : 왜 그래? 왜 테이블이 문제를 일으킬까요?
amitshree

존재하지 않는 '위치'열로 주문하려고합니다. 이 쿼리를 실행 한 후 그룹화 된 제품을 작성하려고 했습니까?
saravanavelu

5

고객을 사로 잡으십시오

TRUNCATE TABLE `customer_address_entity_datetime`;
TRUNCATE TABLE `customer_address_entity_decimal`;
TRUNCATE TABLE `customer_address_entity_int`;
TRUNCATE TABLE `customer_address_entity_text`;
TRUNCATE TABLE `customer_address_entity_varchar`;
DELETE FROM customer_address_entity WHERE 1;
TRUNCATE TABLE `catalog_compare_item`;
DELETE FROM customer_entity WHERE 1;
TRUNCATE TABLE `customer_entity_datetime`;
TRUNCATE TABLE `customer_entity_decimal`;
TRUNCATE TABLE `customer_entity_int`;
TRUNCATE TABLE `customer_entity_text`;
TRUNCATE TABLE `customer_entity_varchar`;
TRUNCATE TABLE `customer_grid_flat`;
TRUNCATE TABLE `customer_log`;
TRUNCATE TABLE `customer_log`;
TRUNCATE TABLE `customer_visitor`;
TRUNCATE TABLE `persistent_session`;
DELETE FROM wishlist WHERE 1;
DELETE FROM wishlist_item WHERE 1;
TRUNCATE TABLE `wishlist_item_option`;

5

모든 리뷰 지우기 :

SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE `rating_option_vote`;
TRUNCATE TABLE `rating_option_vote_aggregated`;
TRUNCATE TABLE `review`;
TRUNCATE TABLE `review_detail`;
TRUNCATE TABLE `review_entity_summary`;
TRUNCATE TABLE `review_store`;

모든 고객 지우기 :

SET FOREIGN_KEY_CHECKS = 0;
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_entity`;
TRUNCATE `customer_entity_datetime`;
TRUNCATE `customer_entity_decimal`;
TRUNCATE `customer_entity_int`;
TRUNCATE `customer_entity_text`;
TRUNCATE `customer_entity_varchar`;

ALTER TABLE `customer_address_entity` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_varchar` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_varchar` AUTO_INCREMENT=1;

모든 제품 지우기 :

SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE `catalog_product_bundle_option`;
TRUNCATE TABLE `catalog_product_bundle_option_value`;
TRUNCATE TABLE `catalog_product_bundle_selection`;
TRUNCATE TABLE `catalog_product_entity_datetime`;
TRUNCATE TABLE `catalog_product_entity_decimal`;
TRUNCATE TABLE `catalog_product_entity_gallery`;
TRUNCATE TABLE `catalog_product_entity_int`;
TRUNCATE TABLE `catalog_product_entity_media_gallery`;
TRUNCATE TABLE `catalog_product_entity_media_gallery_value`;
TRUNCATE TABLE `catalog_product_entity_text`;
TRUNCATE TABLE `catalog_product_entity_tier_price`;
TRUNCATE TABLE `catalog_product_entity_varchar`;
TRUNCATE TABLE `catalog_product_link`;
TRUNCATE TABLE `catalog_product_link_attribute`;
TRUNCATE TABLE `catalog_product_link_attribute_decimal`;
TRUNCATE TABLE `catalog_product_link_attribute_int`;
TRUNCATE TABLE `catalog_product_link_attribute_varchar`;
TRUNCATE TABLE `catalog_product_link_type`;
TRUNCATE TABLE `catalog_product_option`;
TRUNCATE TABLE `catalog_product_option_price`;
TRUNCATE TABLE `catalog_product_option_title`;
TRUNCATE TABLE `catalog_product_option_type_price`;
TRUNCATE TABLE `catalog_product_option_type_title`;
TRUNCATE TABLE `catalog_product_option_type_value`;
TRUNCATE TABLE `catalog_product_super_attribute_label`;
TRUNCATE TABLE `catalog_product_super_attribute`;
TRUNCATE TABLE `catalog_product_super_link`;
TRUNCATE TABLE `catalog_product_website`;
TRUNCATE TABLE `catalog_category_product_index`;
TRUNCATE TABLE `catalog_category_product`;
TRUNCATE TABLE `cataloginventory_stock_item`;
TRUNCATE TABLE `cataloginventory_stock_status`;
TRUNCATE TABLE `cataloginventory_stock`;
TRUNCATE TABLE `catalog_product_entity`;
INSERT  INTO `catalog_product_link_type`(`link_type_id`,`code`) VALUES (1,'relation'),(2,'bundle'),(3,'super'),(4,'up_sell'),(5,'cross_sell');
INSERT  INTO `catalog_product_link_attribute`(`product_link_attribute_id`,`link_type_id`,`product_link_attribute_code`,`data_type`) VALUES (1,2,'qty','decimal'),(2,1,'position','int'),(3,4,'position','int'),(4,5,'position','int'),(6,1,'qty','decimal'),(7,3,'position','int'),(8,3,'qty','decimal');
INSERT  INTO `cataloginventory_stock`(`stock_id`,`website_id`,`stock_name`) VALUES (1,0,'Default');

모든 주문, 선적, 거래 등을 청산 :

SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE `sales_order`;
TRUNCATE `sendfriend_log`;
TRUNCATE `wishlist`;
TRUNCATE `report_event`;

ALTER TABLE `sales_order` AUTO_INCREMENT=1;
ALTER TABLE `sendfriend_log` AUTO_INCREMENT=1;
ALTER TABLE `wishlist` AUTO_INCREMENT=1;
ALTER TABLE `report_event` AUTO_INCREMENT=1;

주문 증분 ID를 제거하지 않습니다.
chirag

3

카테고리 분류 및 루트 카테고리 작성

SET FOREIGN_KEY_CHECKS = 0;

TRUNCATE TABLE`catalog_category_entity`; 
TRUNCATE TABLE`catalog_category_entity_datetime`; 
TRUNCATE TABLE`catalog_category_entity_decimal`; 
TRUNCATE TABLE`catalog_category_entity_int`; 
TRUNCATE TABLE`catalog_category_entity_text`; 
TRUNCATE TABLE`catalog_category_entity_varchar`; 
TRUNCATE TABLE`catalog_category_product`; 
TRUNCATE TABLE`catalog_category_product_index`;

`catalog_category_entity`에 삽입 (`entity_id`,`attribute_set_id`,`parent_id`,`created_at`,`updated_at`,`path`,`position`,`level`,`children_count`) VALUES ( '1', '0 ','0 ','2016-06-23 00:00:00 ','2016-06-23 00:00:00 ','1 ','0 ','0 ','1 '), ( '2', '3', '1', '2016-06-23 00:00:00', '2016-06-23 00:00:00', '1/2', '1', '1 ','0 ');
`catalog_category_entity_datetime` (`value_id`,`attribute_id`,`store_id`,`entity_id`,`value`)에 삽입 VALUES ( '1', '58', '0', '1', NULL), (2, 58, 0, 2, NULL);
`catalog_category_entity_decimal`에 삽입 (`value_id`,`attribute_id`,`store_id`,`entity_id`,`value`) 값
(1, 69, 0, 2, NULL);
`catalog_category_entity_int` (`value_id`,`attribute_id`,`store_id`,`entity_id`,`value`)에 삽입 VALUES ( '1', '66', '0', '1', '1'), ( 2, 43, 0, 2, 1), (3, 50, 0, 2, NULL), (4, 51, 0, 2, 1), (5, 66, 0, 2, 1), (6, 68, 0, 2, 0);
`catalog_category_entity_text` (`value_id`,`attribute_id`,`store_id`,`entity_id`,`value`)에 삽입 VALUES ( '1', '64', '0', '1', NULL), (2, 64, 0, 2, NULL), (3, 44, 0, 2, NULL), (4, 47, 0, 2, NULL), (5, 48, 0, 2, NULL), (6, 61, 0, 2, NULL);
`catalog_category_entity_varchar`에 삽입 (`value_id`,`attribute_id`,`store_id`,`entity_id`,`value`) VALUES ( '1', '42', '0', '1', 'Root Catalog');
`catalog_category_entity_varchar` (`value_id`,`attribute_id`,`store_id`,`entity_id`,`value`)에 삽입 VALUES (2, 42, 0, 2, 'Default Category'), (3, 46, 0, 2 , NULL), (4, 49, 0, 2, 'PRODUCTS'), (5, 57, 0, 2, NULL), (6, 60, 0, 2, NULL), (7, 65, 0, 2 , NULL), (8, 113, 0, 2, 'default-category'), (9, 114, 0, 2, NULL), (10, 143, 0, 2, NULL), (11, 145, 0 , 2, NULL), (12, 147, 0, 2, NULL);

SET FOREIGN_KEY_CHECKS = 1;

2

잘린 카테고리

TRUNCATE TABLE `catalog_category_entity`; 
TRUNCATE TABLE `catalog_category_entity_datetime`; 
TRUNCATE TABLE `catalog_category_entity_decimal`; 
TRUNCATE TABLE `catalog_category_entity_int`; 
TRUNCATE TABLE `catalog_category_entity_text`; 
TRUNCATE TABLE `catalog_category_entity_varchar`; 
TRUNCATE TABLE `catalog_category_product`; 
TRUNCATE TABLE `catalog_category_product_index`;


INSERT  INTO `catalog_category_entity`(`entity_id`,`attribute_set_id`,`parent_id`,`created_at`,`updated_at`,`path`,`POSITION`,`level`,`children_count`) VALUES (1,0,0,'2009-02-20 00:25:34','2009-02-20 00:25:34','1',1,0,1),(2,3,0,'2009-02-20 00:25:34','2009-02-20 00:25:34','1/2',1,1,0); 
INSERT  INTO `catalog_category_entity_int`(`value_id`,`attribute_id`,`store_id`,`entity_id`,`value`) VALUES (1,32,0,2,1),(2,32,1,2,1); 
INSERT  INTO `catalog_category_entity_varchar`(`value_id`,`attribute_id`,`store_id`,`entity_id`,`value`) VALUES (1,31,0,1,'Root Catalog'),(2,33,0,1,'root-catalog'),(3,31,0,2,'Default Category'),(4,39,0,2,'PRODUCTS'),(5,33,0,2,'default-category');

2

catalog_product_link_attribute테이블을 자르지 마십시오. 그렇지 않으면 그룹화 된 제품을 만드는 데 문제가 발생합니다. 그 외에는 @amitshree https://magento.stackexchange.com/a/102995/14787에 언급 된대로 다른 테이블을자를 수 있습니다.

해당 테이블을 이미 잘린 경우 다음과 같이 레코드를 삽입하십시오.

INSERT INTO `catalog_product_link_attribute` VALUES (1,1,'position','int'),(2,4,'position','int'),(3,5,'position','int'),(4,3,'position','int'),(5,3,'qty','decimal');

2

이 올바른 것

DELETE FROM catalog_product_entity;

자르기를 사용하면 자동 증분 값도 재설정되므로 새 항목의 ID가 1부터 다시 시작되므로 잘림을 사용하는 것이 좋습니다.
Ziki

알았어 @ 지키를 시도합니다
Gowthaman

2

여기의 Magento 2.2.6은 bin / magento sampledata : remove 후에 데이터베이스를 정리해야했습니다.

짧은 이야기, 주문 , 고객리뷰에 대한 위의 SQL 은 여전히 ​​작동 ALTER TABLE xxx AUTO_INCREMENT=1;하지만 ( 추가해야 함 ) 카테고리제품에 대한 몇 가지 사항을 조정해야했습니다 .

이 새로운 요약이 다른 사람을 도울 수 있다고 생각합니다.

카테고리

SET FOREIGN_KEY_CHECKS = 0;

DELETE FROM `m_url_rewrite` WHERE `entity_type` = 'category';

TRUNCATE TABLE `m_catalog_category_entity`;
TRUNCATE TABLE `m_catalog_category_entity_datetime`;
TRUNCATE TABLE `m_catalog_category_entity_decimal`;
TRUNCATE TABLE `m_catalog_category_entity_int`;
TRUNCATE TABLE `m_catalog_category_entity_text`;
TRUNCATE TABLE `m_catalog_category_entity_varchar`;
TRUNCATE TABLE `m_catalog_category_flat_store_1`;
TRUNCATE TABLE `m_catalog_category_flat_store_2`;
TRUNCATE TABLE `m_catalog_category_product`;
TRUNCATE TABLE `m_catalog_category_product_index`;
TRUNCATE TABLE `m_catalog_category_product_index_replica`;
TRUNCATE TABLE `m_catalog_category_product_index_store1`;
TRUNCATE TABLE `m_catalog_category_product_index_store1_replica`;
TRUNCATE TABLE `m_catalog_category_product_index_store2`;
TRUNCATE TABLE `m_catalog_category_product_index_store2_replica`;
TRUNCATE TABLE `m_catalog_category_product_index_tmp`;

ALTER TABLE `m_catalog_category_entity` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_entity_varchar` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_flat_store_1` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_flat_store_2` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_product` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_product_index` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_product_index_replica` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_product_index_store1` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_product_index_store1_replica` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_product_index_store2` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_product_index_store2_replica` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_product_index_tmp` AUTO_INCREMENT=1;

INSERT INTO `m_catalog_category_entity` (`entity_id`, `attribute_set_id`, `parent_id`, `created_at`, `updated_at`, `path`, `position`, `level`, `children_count`) VALUES ('1', '0', '0', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, '1', '0', '0', '1'),
('2', '3', '1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, '1/2', '1', '1', '0');
INSERT INTO `m_catalog_category_entity_int` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES
('1', '69', '0', '1', '1'),
('2', '46', '0', '2', '1'),
('3', '69', '0', '2', '1');
INSERT INTO `m_catalog_category_entity_varchar` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES
('1', '45', '0', '1', 'Root Catalog'),
('2', '45', '0', '2', 'Default Category'),
('3', '52', '0', '2', 'PRODUCTS');

SET FOREIGN_KEY_CHECKS = 1;

제작품

SET FOREIGN_KEY_CHECKS = 0;

DELETE FROM `m_url_rewrite` WHERE `entity_type` = 'product';

TRUNCATE TABLE `m_cataloginventory_stock_item`;
TRUNCATE TABLE `m_cataloginventory_stock_status`;
TRUNCATE TABLE `m_cataloginventory_stock_status_idx`;
TRUNCATE TABLE `m_cataloginventory_stock_status_tmp`;
TRUNCATE TABLE `m_cataloginventory_stock`;
TRUNCATE TABLE `m_catalog_category_product`;
TRUNCATE TABLE `m_catalog_category_product_index`;
TRUNCATE TABLE `m_catalog_category_product_index_tmp`;
TRUNCATE TABLE `m_catalog_compare_item`;
TRUNCATE TABLE `m_catalog_product_bundle_option`;
TRUNCATE TABLE `m_catalog_product_bundle_option_value`;
TRUNCATE TABLE `m_catalog_product_bundle_price_index`;
TRUNCATE TABLE `m_catalog_product_bundle_selection`;
TRUNCATE TABLE `m_catalog_product_bundle_selection_price`;
TRUNCATE TABLE `m_catalog_product_bundle_stock_index`;
TRUNCATE TABLE `m_catalog_product_entity_datetime`;
TRUNCATE TABLE `m_catalog_product_entity_decimal`;
TRUNCATE TABLE `m_catalog_product_entity_gallery`;
TRUNCATE TABLE `m_catalog_product_entity_int`;
TRUNCATE TABLE `m_catalog_product_entity_media_gallery`;
TRUNCATE TABLE `m_catalog_product_entity_media_gallery_value`;
TRUNCATE TABLE `m_catalog_product_entity_media_gallery_value_to_entity`;
TRUNCATE TABLE `m_catalog_product_entity_media_gallery_value_video`;
TRUNCATE TABLE `m_catalog_product_entity_text`;
TRUNCATE TABLE `m_catalog_product_entity_tier_price`;
TRUNCATE TABLE `m_catalog_product_entity_varchar`;
TRUNCATE TABLE `m_catalog_product_link`;
TRUNCATE TABLE `m_catalog_product_link_attribute`;
TRUNCATE TABLE `m_catalog_product_link_attribute_decimal`;
TRUNCATE TABLE `m_catalog_product_link_attribute_int`;
TRUNCATE TABLE `m_catalog_product_link_attribute_varchar`;
TRUNCATE TABLE `m_catalog_product_link_type`;
TRUNCATE TABLE `m_catalog_product_option`;
TRUNCATE TABLE `m_catalog_product_option_price`;
TRUNCATE TABLE `m_catalog_product_option_title`;
TRUNCATE TABLE `m_catalog_product_option_type_price`;
TRUNCATE TABLE `m_catalog_product_option_type_title`;
TRUNCATE TABLE `m_catalog_product_option_type_value`;
TRUNCATE TABLE `m_catalog_product_super_attribute`;
TRUNCATE TABLE `m_catalog_product_super_attribute_label`;
TRUNCATE TABLE `m_catalog_product_super_link`;
TRUNCATE TABLE `m_catalog_product_index_eav`;
TRUNCATE TABLE `m_catalog_product_index_eav_decimal`;
TRUNCATE TABLE `m_catalog_product_index_eav_decimal_idx`;
TRUNCATE TABLE `m_catalog_product_index_eav_decimal_replica`;
TRUNCATE TABLE `m_catalog_product_index_eav_decimal_tmp`;
TRUNCATE TABLE `m_catalog_product_index_eav_idx`;
TRUNCATE TABLE `m_catalog_product_index_eav_replica`;
TRUNCATE TABLE `m_catalog_product_index_eav_tmp`;
TRUNCATE TABLE `m_catalog_product_index_price`;
TRUNCATE TABLE `m_catalog_product_index_price_bundle_idx`;
TRUNCATE TABLE `m_catalog_product_index_price_bundle_opt_idx`;
TRUNCATE TABLE `m_catalog_product_index_price_bundle_opt_tmp`;
TRUNCATE TABLE `m_catalog_product_index_price_bundle_sel_idx`;
TRUNCATE TABLE `m_catalog_product_index_price_bundle_sel_tmp`;
TRUNCATE TABLE `m_catalog_product_index_price_bundle_tmp`;
TRUNCATE TABLE `m_catalog_product_index_price_cfg_opt_agr_idx`;
TRUNCATE TABLE `m_catalog_product_index_price_cfg_opt_agr_tmp`;
TRUNCATE TABLE `m_catalog_product_index_price_cfg_opt_idx`;
TRUNCATE TABLE `m_catalog_product_index_price_cfg_opt_tmp`;
TRUNCATE TABLE `m_catalog_product_index_price_downlod_idx`;
TRUNCATE TABLE `m_catalog_product_index_price_downlod_tmp`;
TRUNCATE TABLE `m_catalog_product_index_price_final_idx`;
TRUNCATE TABLE `m_catalog_product_index_price_final_tmp`;
TRUNCATE TABLE `m_catalog_product_index_price_idx`;
TRUNCATE TABLE `m_catalog_product_index_price_opt_agr_idx`;
TRUNCATE TABLE `m_catalog_product_index_price_opt_agr_tmp`;
TRUNCATE TABLE `m_catalog_product_index_price_opt_idx`;
TRUNCATE TABLE `m_catalog_product_index_price_opt_tmp`;
TRUNCATE TABLE `m_catalog_product_index_price_replica`;
TRUNCATE TABLE `m_catalog_product_index_price_tmp`;
TRUNCATE TABLE `m_catalog_product_index_tier_price`;
TRUNCATE TABLE `m_catalog_product_index_website`;
TRUNCATE TABLE `m_catalog_product_website`;
TRUNCATE TABLE `m_catalog_product_flat_1`;
TRUNCATE TABLE `m_catalog_product_flat_2`;
TRUNCATE TABLE `m_catalog_product_relation`;
TRUNCATE TABLE `m_catalog_product_frontend_action`;
TRUNCATE TABLE `m_catalog_url_rewrite_product_category`;
TRUNCATE TABLE `m_downloadable_link`;
TRUNCATE TABLE `m_downloadable_link_price`;
TRUNCATE TABLE `m_downloadable_link_purchased`;
TRUNCATE TABLE `m_downloadable_link_purchased_item`;
TRUNCATE TABLE `m_downloadable_link_title`;
TRUNCATE TABLE `m_downloadable_sample`;
TRUNCATE TABLE `m_downloadable_sample_title`;
TRUNCATE TABLE `m_product_alert_price`;
TRUNCATE TABLE `m_product_alert_stock`;
TRUNCATE TABLE `m_report_compared_product_index`;
TRUNCATE TABLE `m_report_viewed_product_aggregated_daily`;
TRUNCATE TABLE `m_report_viewed_product_aggregated_monthly`;
TRUNCATE TABLE `m_report_viewed_product_aggregated_yearly`;
TRUNCATE TABLE `m_report_viewed_product_index`;
TRUNCATE TABLE `m_catalog_product_entity`;

ALTER TABLE `m_cataloginventory_stock_item` AUTO_INCREMENT=1;
ALTER TABLE `m_cataloginventory_stock_status` AUTO_INCREMENT=1;
ALTER TABLE `m_cataloginventory_stock_status_idx` AUTO_INCREMENT=1;
ALTER TABLE `m_cataloginventory_stock_status_tmp` AUTO_INCREMENT=1;
ALTER TABLE `m_cataloginventory_stock` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_product` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_product_index` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_category_product_index_tmp` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_compare_item` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_bundle_option` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_bundle_option_value` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_bundle_price_index` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_bundle_selection` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_bundle_selection_price` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_bundle_stock_index` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_entity_gallery` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_entity_media_gallery` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_entity_media_gallery_value` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_entity_media_gallery_value_to_entity` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_entity_media_gallery_value_video` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_entity_tier_price` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_entity_varchar` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_link` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_link_attribute` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_link_attribute_decimal` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_link_attribute_int` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_link_attribute_varchar` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_link_type` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_option` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_option_price` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_option_title` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_option_type_price` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_option_type_title` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_option_type_value` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_super_attribute` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_super_attribute_label` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_super_link` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_eav` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_eav_decimal` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_eav_decimal_idx` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_eav_decimal_replica` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_eav_decimal_tmp` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_eav_idx` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_eav_replica` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_eav_tmp` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_bundle_idx` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_bundle_opt_idx` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_bundle_opt_tmp` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_bundle_sel_idx` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_bundle_sel_tmp` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_bundle_tmp` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_cfg_opt_agr_idx` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_cfg_opt_agr_tmp` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_cfg_opt_idx` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_cfg_opt_tmp` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_downlod_idx` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_downlod_tmp` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_final_idx` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_final_tmp` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_idx` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_opt_agr_idx` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_opt_agr_tmp` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_opt_idx` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_opt_tmp` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_replica` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_price_tmp` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_tier_price` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_index_website` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_website` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_flat_1` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_flat_2` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_relation` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_frontend_action` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_url_rewrite_product_category` AUTO_INCREMENT=1;
ALTER TABLE `m_downloadable_link` AUTO_INCREMENT=1;
ALTER TABLE `m_downloadable_link_price` AUTO_INCREMENT=1;
ALTER TABLE `m_downloadable_link_purchased` AUTO_INCREMENT=1;
ALTER TABLE `m_downloadable_link_purchased_item` AUTO_INCREMENT=1;
ALTER TABLE `m_downloadable_link_title` AUTO_INCREMENT=1;
ALTER TABLE `m_downloadable_sample` AUTO_INCREMENT=1;
ALTER TABLE `m_downloadable_sample_title` AUTO_INCREMENT=1;
ALTER TABLE `m_product_alert_price` AUTO_INCREMENT=1;
ALTER TABLE `m_product_alert_stock` AUTO_INCREMENT=1;
ALTER TABLE `m_report_compared_product_index` AUTO_INCREMENT=1;
ALTER TABLE `m_report_viewed_product_aggregated_daily` AUTO_INCREMENT=1;
ALTER TABLE `m_report_viewed_product_aggregated_monthly` AUTO_INCREMENT=1;
ALTER TABLE `m_report_viewed_product_aggregated_yearly` AUTO_INCREMENT=1;
ALTER TABLE `m_report_viewed_product_index` AUTO_INCREMENT=1;
ALTER TABLE `m_catalog_product_entity` AUTO_INCREMENT=1;

INSERT  INTO `m_catalog_product_link_type`(`link_type_id`,`code`) VALUES (1,'relation'),(2,'bundle'),(3,'super'),(4,'up_sell'),(5,'cross_sell');
INSERT  INTO `m_catalog_product_link_attribute`(`product_link_attribute_id`,`link_type_id`,`product_link_attribute_code`,`data_type`) VALUES (1,2,'qty','decimal'),(2,1,'position','int'),(3,4,'position','int'),(4,5,'position','int'),(6,1,'qty','decimal'),(7,3,'position','int'),(8,3,'qty','decimal');
INSERT  INTO `m_cataloginventory_stock`(`stock_id`,`website_id`,`stock_name`) VALUES (1,0,'Default');

SET FOREIGN_KEY_CHECKS = 1;

1

카테고리 테이블을 자른 후 URL 키에 대한 중복 입력 오류가 발생할 수 있으므로 url_rewrite테이블 에서 카테고리 URL 키를 지워야 합니다.

DELETE FROM `url_rewrite` WHERE `entity_type` = 'category'

1

모든 사람의 대답은 훌륭하지만이 테이블이 잘릴 때 자동 증분이 재설정되는 것이 중요하다고 덧붙이고 싶습니다. 일반적으로 MySQL은 자동 으로이 작업을 수행하지만 두 개의 별도 환경에서는 재설정되지 않는 수많은 문제가 발생했습니다. REGEX를 사용하여 위의 답변을 찾아서 바꾸어 각 TRUNCATE 후에 ALTER TABLE을 추가했습니다. 위의 증상 / 문제는 대부분 잘린 모든 테이블에서 AUTO_INCREMENTS를 재설정 할 때까지 나타납니다.


0

데이터베이스에서 사용자 세부 사항을 지우려면 다음 단계를 수행하십시오.

SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE `customer_address_entity`;
TRUNCATE TABLE `customer_address_entity_datetime`;
TRUNCATE TABLE `customer_address_entity_decimal`;
TRUNCATE TABLE `customer_address_entity_int`;
TRUNCATE TABLE `customer_address_entity_text`;
TRUNCATE TABLE `customer_address_entity_varchar`;
TRUNCATE TABLE `customer_entity`;
TRUNCATE TABLE `customer_entity_datetime`;
TRUNCATE TABLE `customer_entity_decimal`;
TRUNCATE TABLE `customer_entity_int`;
TRUNCATE TABLE `customer_entity_text`;
TRUNCATE TABLE `customer_entity_varchar`;
TRUNCATE TABLE `customer_grid_flat`;
TRUNCATE TABLE `customer_log`;
TRUNCATE TABLE `customer_log`;
TRUNCATE TABLE `customer_visitor`;
TRUNCATE TABLE `persistent_session`;
TRUNCATE TABLE `wishlist`;
TRUNCATE TABLE `wishlist_item`;
TRUNCATE TABLE `wishlist_item_option`;
SET FOREIGN_KEY_CHECKS = 1;

그러면 모든 사용자가 제거되고 1에서 엔티티 ID가 시작됩니다.

당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.