商品表的sql

# tinyint : 0~255
# smallint : 0~ 65535
# mediumint : 0~1千6百多萬
# int : 0~40多億
# char 、varchar 、 text容量?
# char    :0~255個字符
# varchar : 0~65535 字節 看錶編碼,如果是utf8存2萬多漢字 gbk存3萬多漢字
# text    : 0~65535 字符
CREATE TABLE IF NOT EXISTS php34_goods
(
	id mediumint unsigned not null auto_increment,
	goods_name varchar(45) not null comment '商品名稱',
	logo varchar(150) not null default '' comment '商品logo',
	sm_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 is_delete(is_delete),
	key addtime(addtime)
)engine=MyISAM default charset=utf8;
#說明:當要使用LIKE 查詢並以%開頭時,不能使用普通索引,只以使用全文索引,如果使用了全文索引:
#SELECT * FROM php34_goods WHERE MATCH goods_name AGAINST 'xxxx';
# 但MYSQL自帶的全文索引不支持中文,所以不能使用MYSQL自帶的全文索引功能,所以如果要優化只能使用第三方的全文索引## 引擎,如:sphinx,lucence等。


#decimal(10,2)  意思是10位數字,其中兩位是小數

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章