php 将索引添加到mysql中的列
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14419090/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Adding Index to column in mysql
提问by Albi Hoti
How do I create an index with PHPmyadmin?
如何使用 PHPmyadmin 创建索引?
I have a database with 5,000 rows of
我有一个包含 5,000 行的数据库
ID | IP | DATE
Before added data to this table I made idas Primary Key,
在将数据添加到我id作为主键的这张表之前,
The website use this query:
该网站使用此查询:
mysql_query("SELECT * FROM users WHERE ip = '$ip'");
I read today that indexes can speed up and performance, and in my case how do i need to add index to IP column,
我今天读到索引可以提高速度和性能,在我的情况下,我需要如何向 IP 列添加索引,
I am to phpmyadmin and to actions I see "Add unique index" and "Add index" options, Im new in this, appreciate your help, thank you.
我是 phpmyadmin 和我看到“添加唯一索引”和“添加索引”选项的操作,我是新手,感谢您的帮助,谢谢。
回答by Viacheslav Kondratiuk
Or you can run a query:
或者您可以运行查询:
ALTER TABLE `users` ADD INDEX `ip` (`ip`)
回答by John Conde
Click on the icon that says "index" in the row for ip. (It's the one with the lightening bolt). Don't choose primary keyor unique. Just index.
单击 的行中显示“索引”的图标ip。(它是带有闪电螺栓的那个)。不要选择primary key或unique。只是索引。

