为什么我的mysql索引不能在sqlfiddle上工作?

vof42yt1  于 2021-06-21  发布在  Mysql
关注(0)|答案(0)|浏览(152)

这是我的table:

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 * from item USE INDEX(i1);

我得到的结果:我得到的
我想要的结果是:我想要的
我在跟踪https://dev.mysql.com/doc/refman/5.6/en/index-hints.html 作为一个指导方针,但没有用。。。。
这些是我的指示
通过执行以下操作,使用包含产品信息字段的表,开发sql代码以创建产品名称字段的“索引”:
1) 提供您为创建产品信息的“索引”而编写的sql代码。
我想出来了。工作index:proof updated 代码:

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);

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题