mysql 创建表时建立索引_MySQL 建表 如何建立索引更有利

CREATE TABLE `typecho_album` (

`id` int(10) unsigned NOT NULL auto_increment,

`name` text,

`mime` varchar(32) default NULL,

`pixel` text,

`size` int(12) unsigned default '0',

`created` int(10) unsigned default '0',

`description` text,

`url` text,

`thumb` text,

`public` int(1) unsigned default '1',

`from` varchar(32) default NULL,

`category` varchar(32) default NULL,

PRIMARY KEY (`id`)

) ENGINE=MyISAM DEFAULT CHARSET=%charset%;

这样一个表 要建立一个索引

看了不少 还是迷糊 看看大家的说法

检索方式

select * from table

可能存在的条件

where public = 1 (pubilc 只有 0 和 1 二个值)

where from = xxx (from 有3个值)

where category = xx (category 有1-N 个值 不确定)

where created < xx and created > xx ( 这个是重点 created 是创建时间,通过时间范围检索,比如 一天,一星期, 一个月,一年)

以上条件 可能都存在 可能都不存在 也可能其中1个或者多个

谢谢!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值