0

If I have a table with a primary_key and an Integer and I want to index the Integer, how would I do that?

Also, when I INSERT or UPDATE or DELETE a row do I have to reindex or is this done automatically? If so, how do I do that?

Trevor Wood
  • 2,347
  • 5
  • 31
  • 56
  • 2
    (1) You would create an index on the column; (2) Databases maintain the indexes, so there is no need to "re-index" (although de-fragmenting is sometimes desirable). – Gordon Linoff Feb 27 '16 at 02:18
  • Possible duplicate of [How do I add indexes to MySQL tables?](http://stackoverflow.com/questions/3002605/how-do-i-add-indexes-to-mysql-tables) – Drew Feb 27 '16 at 02:21
  • @GordonLinoff Thanks! Also, when I use `WHERE` on the indexed column do I have to state that it's indexed? – Trevor Wood Feb 27 '16 at 02:30
  • 2
    @TrevorWood . . . You don't need to. That is one thing that the query compiler/optimizer does. – Gordon Linoff Feb 27 '16 at 02:31

0 Answers0