1
  1. MYISAM table type or engine - creates 3 files on disk for each table.

    1. for structure .frm
    2. for data .myd
    3. for index .myi If I create new index for already existed table, which files from above get changed?
  2. When we create index, what exactly happends to the data in table? does the records in table get chenged for indexed column?

  3. If we insert new record as name = aaass, salary = 40500, at which position the record is stored? at the end? or as we created index, it will store bellow the name= aaab?

e.g table is

id name salary
1  aaa   20000
2  ddd   23000
3  aaabb 10000
4  dddqa 40000

if I create index on name, then does data gets rearraged as follows?

id name salary
1  aaa   20000
3  aaabb 10000
2  ddd   23000
4  dddqa 40000

If not then what is the use of index?

4

1 回答 1

0

如果您为已经存在的表创建一个新索引,那么.frm文件.myi应该得到更新,因为.frm将在表定义中使用新索引进行更新,并且myi文件将使用新的索引树进行更新。

PRIMARY KEY在表上定义的clustured index记录是根据键顺序按排序顺序存储的。

于 2012-09-11T10:45:33.903 回答