Mysql“select * from"不返回所有行

2021-12-30 00:00:00 sql rows select count mysql

我已经习惯了 PostgreSQL 并且不理解 MySQL 上的这种行为.

I'm used to PostgreSQL and don't understand this behaviour on MySQL.

此表(来自 SugarCRM)有 3057 行:

This table (from SugarCRM) has 3057 rows:

mysql> SELECT  count(*) FROM tasks ;
+----------+
| count(*) |
+----------+
|     3057 |
+----------+

但是在运行 SELECT * FROM tasks 时:

mysql> SELECT * FROM tasks ;
...
2344 rows in set (0,02 sec)

我使用的是相当旧版本的 MySQL,但问题是我只是想转储数据库并恢复到新版本.

I'm using a fairly old version of MySQL, but the issue is I'm just trying to dump the database and restore to a new version.

# mysql --version
mysql  Ver 14.14 Distrib 5.1.51, for slackware-linux-gnu (x86_64) using  EditLine wrapper

你有什么想法吗?

推荐答案

通常 MyISAM 表格式非常可靠,但有时表会因各种原因而损坏,例如硬件故障、mysqld 进程在写操作进行时被终止、不合时宜的关闭或 MySQL 或 MyISAM 代码中的错误.如果您使用的是非常旧的版本,则可能存在错误.

Generally MyISAM table format is very reliable but tables can sometime get corrupted for various reasons like Hardware failures, mysqld process is killed while a write operation is underway, untimely shutdowns or bugs in the MySQL or MyISAM code. If you're using a very old version then bugs are likely.

修复前建议备份.修复

REPAIR [NO_WRITE_TO_BINLOG | LOCAL] TABLE
tbl_name [, tbl_name] ...
[QUICK] [EXTENDED] [USE_FRM]

相关文章