> Zencart中文手册 > ZenCart常用SQL语句

1.增加字段长度

以下代码用于在数据库中增大对某些数据的定义值,例如增加商品型号的长度、商品名称的长度、客户姓名的长度、商品分类名称的长度、账单地址的长度等等。在后台的 [ 工具 - 安装sql脚本 ] ,执行

1 ALTER TABLE products MODIFY products_model varchar(256) ;
2 ALTER TABLE products_description MODIFY products_name varchar(256) ;
3 ALTER TABLE address_book MODIFY entry_firstname varchar(256) ;
4 ALTER TABLE address_book MODIFY entry_lastname varchar(256) ;
5 ALTER TABLE categories_description MODIFY categories_name varchar(256) ;
6 ALTER TABLE configuration_group MODIFY configuration_group_title varchar(256) ;
7 ALTER TABLE customers_wishlist MODIFY products_name varchar(256) ;
8 ALTER TABLE customers_wishlist MODIFY wishlist_name varchar(256) ;
9 ALTER TABLE files_uploaded MODIFY files_uploaded_name varchar(256) ;
10 ALTER TABLE orders MODIFY customers_name varchar(256) ;
11 ALTER TABLE orders MODIFY customers_email_address varchar(256) ;
12 ALTER TABLE orders MODIFY delivery_name varchar(256) ;
13 ALTER TABLE orders MODIFY billing_name varchar(256) ;
14 ALTER TABLE orders MODIFY cc_owner varchar(256) ;
15 ALTER TABLE orders_products MODIFY products_name varchar(256) ;
16 ALTER TABLE orders_products MODIFY products_model varchar(256) ;
17 ALTER TABLE address_book MODIFY entry_street_address varchar(256) ;
18 ALTER TABLE products MODIFY products_image varchar(256);

注:合理的字段大小,有利于提高数据库效率

2.清空全部商品和属性

1 # 清空商品分类、商品、属性
2 TRUNCATE TABLE categories;
3 TRUNCATE TABLE categories_description;
4  
5 # 清空商品以及属性
6 TRUNCATE TABLE media_clips;
7 TRUNCATE TABLE media_manager;
8 TRUNCATE TABLE media_to_products;
9 TRUNCATE TABLE media_types;
10 TRUNCATE TABLE music_genre;
11 TRUNCATE TABLE product_music_extra;
12 TRUNCATE TABLE product_types_to_category;
13 TRUNCATE TABLE products;
14 TRUNCATE TABLE products_attributes;
15 TRUNCATE TABLE products_attributes_download;
16 TRUNCATE TABLE products_description;
17 TRUNCATE TABLE products_discount_quAntity;
18 TRUNCATE TABLE products_notifications;
19 TRUNCATE TABLE products_options;
20 TRUNCATE TABLE products_options_values;
21 TRUNCATE TABLE products_options_values_to_products_options;
22 TRUNCATE TABLE products_to_categories;
23 TRUNCATE TABLE record_artists;
24 TRUNCATE TABLE record_artists_info;
25 TRUNCATE TABLE record_company;
26 TRUNCATE TABLE record_company_info;
27  
28 # 清空推荐商品
29 TRUNCATE TABLE featured;
30  
31 # 清空促销商品
32 TRUNCATE TABLE salemaker_sales;
33  
34 # 清空特价商品
35 TRUNCATE TABLE specials;
36  
37 # 清空团体价格
38 TRUNCATE TABLE group_pricing;
39  
40 # 清空厂家及资料
41 TRUNCATE TABLE manufacturers;
42 TRUNCATE TABLE manufacturers_info;
43  
44 # 清空客户评论
45 TRUNCATE TABLE reviews;
46 TRUNCATE TABLE reviews_description;

3.批量设置为免运费

1 UPDATE products SET product_is_always_free_shipping = '1';

改回来只用将0,改为1就可以了