Wednesday, April 22, 2009

MySQL Show table status 显示行数不准

发现MySQL Administrator的库信息里,表的行数每次刷新都不一样
表是之前从某网站导出来的用户资料,InnoDB的
怀疑与engine有关,于是
ALTER TABLE `****` ENGINE=MyISAM;
果然,这回用
SHOW TABLE STATUS;
的显示正确了

然后去MySQL手册上寻求解释,发现了
12.5.5.34. SHOW TABLE STATUS Syntax
Rows 

The number of rows. Some storage engines, such as MyISAM, store the exact count. For other storage engines, such as InnoDB, this value is an approximation, and may vary from the actual value by as much as 40 to 50%. In such cases, use SELECT COUNT(*) to obtain an accurate count. 

The Rows value is NULL for tables in the INFORMATION_SCHEMA database. 

1 comment: