标签:
CREATE TABLE test ( name CHAR(200) NOT NULL, KEY index_name (name(10)));
CREATE TABLE test ( id INT NOT NULL, last_name CHAR(30) NOT NULL, first_name CHAR(30) NOT NULL, PRIMARY KEY (id), INDEX name (last_name,first_name));
那么索引name是一个在last_name和first_name上的索引,这个索引将被用于在last_name或last_name和first_name的一个已知范围内指定值的查询,因此,name索引将使用在下列查询中:
SELECT * FROM test WHERE last_name=”Widenius”; SELECT * FROM test WHERE last_name=”Widenius” AND first_name=”Michael”; SELECT * FROM test WHERE last_name=”Widenius” AND (first_name=”Michael” OR first_name=”Monty”); SELECT * FROM test WHERE last_name=”Widenius” AND first_name >=”M” AND first_name < "N";
SELECT * FROM test WHERE first_name=”Michael”; SELECT * FROM test WHERE last_name=”Widenius” OR first_name=”Michael”;
标签:
原文地址:http://www.cnblogs.com/wicub/p/5326394.html