tp京东商城

实际操作:

  1. 建商品表

a) 表都加前缀

b) 所有的字段选择最小的数据类型,如id可以使用mediumint(3个字节)INT(4个字节)节省25%的空间

c) 尽量所有的字段都设置为NOT NULL的,这样能让速度更快

d) 为合适的字段(将来用来查询或者排序的字段)建索引

 

范围

#tinyint:0~255

#smallint:0~65535

#mediumint:0~1千6百多万

#int :0~40多亿

#char :0~255个字节

#varchar :0~65535个字节(uft-8:2万多汉子,gbk:3万多汉子)

#text :0~65535 字符

 

创建商品表

CREAT TABLE IF NOT EXISTS dh_goods

{

  id mediumint unsigned not null auto_increment,

      goods_name varchar(45) not null default '' comment '商品名称',

  logo varchar(150) not null default '' comment '商品缩量图logo',

  price decimal(10,2)not null default '0.00' comment '商品价格',

  goods_desc longtext comment '商品描述',

  is_on_sale tinyint unsigned not null default '1' comment '是否上架:1上架  0:下架',

  is_delete tinyint unsigned not null default '0' comment '是否已经删除,1:已经删除 0:未删除',

addtime int unsigned not null comment '添加时间',

primary key(id),

key price(price),

key is_on_sale(is_on_sale),

key addtime(addtime),

 

}engine=MyISAM default charset=utf8;

 

 

一般价格用decimal(10,2)   表示价格有10位,小数位2位,其他8位是整数位数

 

 

原文地址:https://www.cnblogs.com/dh2608/p/5774395.html