Adding Index to column in mysql [closed]

女生的网名这么多〃 提交于 2020-05-15 04:35:09

问题


How do I create an index with PHPmyadmin?

I have a database with 5,000 rows of

ID | IP | DATE

Before added data to this table I made id as Primary Key,

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,

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.


回答1:


Click on the icon that says "index" in the row for ip. (It's the one with the lightening bolt). Don't choose primary key or unique. Just index.




回答2:


Or you can run a query:

ALTER TABLE `users` ADD INDEX `ip` (`ip`)


来源:https://stackoverflow.com/questions/14419090/adding-index-to-column-in-mysql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!