为什么我的MySQL索引不能在SQLFiddle上运行?

时间:2018-07-20 17:20:37

标签: mysql sqlfiddle

这是我的桌子:

create table item (`Product ID` int not NULL AUTO_INCREMENT,
`Per/Unit` varchar(50) not null,
Product varchar(50) not null,
Details varchar(200),
PRIMARY KEY (`Product ID`));

INSERT INTO item(Product,Details,`Per/Unit`)
VALUES
('Big Burger Deluxe','Single Patty with Cheese','$1.99'),
('Double Big','2 Patties on a Bun','$2.99'),
('Happy Size Fries','10oz Fries w/ Seasoning','$0.99'),
('Chocolate Shake','Thick Chocolate Shake','$1.49'),
('Strawberry Shake','Thick Strawberry Shake','$1.49'),
('Cherry Pie','Deep-fried cherry Pie with Cream Cheese Icing.','$1.29');create View item_view as select Product from item;

create index i1 on item(Product);

这是我的SELECT语句:

select * from item USE INDEX(i1);

我得到的结果是: What I Get

我希望结果是: What I Want

我遵循https://dev.mysql.com/doc/refman/5.6/en/index-hints.html作为指导,但无济于事。...

更新这些是我的说明

开发SQL代码为产品名称字段创建“索引” 通过以下方式使用包含产品信息字段的表 执行以下操作:

1)提供您编写的SQL代码,以创建“索引” 产品信息。


我知道了。工作指数:Proof 更新的代码:

create table item (`Product ID` int not NULL AUTO_INCREMENT,`Per/Unit` varchar(50) not null,
Product varchar(50) not null, Details varchar(200), PRIMARY KEY (`Product ID`)); INSERT INTO item(Product,Details,`Per/Unit`) 
VALUES
('Big Burger Deluxe','Single Patty with Cheese','$1.99'),
('Double Big','2 Patties on a Bun','$2.99'),
('Happy Size Fries','10oz Fries w/ Seasoning','$0.99'),
('Chocolate Shake','Thick Chocolate Shake','$1.49'),
 ('Strawberry Shake','Thick Strawberry Shake','$1.49'),
('Cherry Pie','Deep-fried cherry Pie with Cream Cheese Icing.','$1.29');
create View item_view as select Product from item;
 create index `i1` on `item` (`Product` ASC);

0 个答案:

没有答案