如何重新索引MySQL列?

assume MySQĹ table:

col_1    col_2    col_3
data_1x  data_2x  2
data_1x  data_2x  5
data_1x  data_2x  9

What is the easiest way to re-index col_3 to receive this...

col_1    col_2    col_3
data_1x  data_2x  1
data_1x  data_2x  2
data_1x  data_2x  3

The col_3 is a simple integer which is not primary or foreigner key. Any help is appreciated.

Try this:-

UPDATE TAB
SET col1 = (SELECT (@rownum := @rownum + 1) FROM (SELECT @rownum := 0) r)

I think this might help you.

SELECT    col_1,
          col_2,
          @curRank := @curRank + 1 AS col_3
FROM      table_name p, (SELECT @curRank := 0) r
ORDER BY  col_1;

best and fastest way:

alter table mytable drop column col_3;
alter table mytable add column col_3 int auto_increment primary key;