请问MYSQL中的key的用法是什么样的
请问MYSQL中的key的用法是什么样的,有什么用啊,例如
//商品类别表
create table mall_category(
category_id int(20) not null auto_increment,
category_name varchar(20) not null default '',
primary key (category_id),
unique key category_name(category_name)
);
//商品信息表
create table mall_products(
product_id int(40) not null auto_increment,
category_id int(20) not null default '0',
product_name varchar(40) not null default '',
product_price double(40) not null default '0.00',
product_detail text not null default '',
product_photo varchar(255) not null default '',
product_commend tinyint(1) not null default '0',
post_datetime datetime not null default '0000-00-00 00:00:00',
primary key(product_id),
key category_id(category_id)
);
key 有什么用呀!!!
//商品类别表
create table mall_category(
category_id int(20) not null auto_increment,
category_name varchar(20) not null default '',
primary key (category_id),
unique key category_name(category_name)
);
//商品信息表
create table mall_products(
product_id int(40) not null auto_increment,
category_id int(20) not null default '0',
product_name varchar(40) not null default '',
product_price double(40) not null default '0.00',
product_detail text not null default '',
product_photo varchar(255) not null default '',
product_commend tinyint(1) not null default '0',
post_datetime datetime not null default '0000-00-00 00:00:00',
primary key(product_id),
key category_id(category_id)
);
key 有什么用呀!!!
作者: xiaozhe339 发布时间: 2011-05-15
key 就是index 创建常规索引的时候使用
作者: 焦占晓 发布时间: 2011-05-15
创建索引用的,可以去看看高老师的数据库视频
作者: 卖身葬小强 发布时间: 2011-05-15