Mysql“select * from”不返回所有行 [英] Mysql "select * from" doesn't return all rows

查看:826
本文介绍了Mysql“select * from”不返回所有行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



这个表(来自SugarCRM)有3057行:

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

但是当运行 SELECT * FROM tasks

  mysql> SELECT * FROM任务; 
...
集合中的2344行(0,02秒)

我使用一个相当老版本的MySQL,但问题是我只是试图转储数据库,并恢复到一个新的版本。

 #mysql --version 
mysql版本14.14 Distrib 5.1.51,对于slackware-linux-gnu(x86_64)使用EditLine包装器

你有什么想法吗?

解决方案

一般来说MyISAM表格式可靠但表有时可能会由于各种原因,如硬件故障,mysqld进程被杀死,而正在进行写操作,不合时宜的关机或错误在MySQL或MyISAM代码损坏。如果您使用的是旧版本,则可能会出现错误。



在修复之前,建议您备份。修复

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


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

This table (from SugarCRM) has 3057 rows:

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

But when running SELECT * FROM tasks :

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

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

Do you have any ideas?

解决方案

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.

Before repairing it is recommended that you backup. To repair

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

这篇关于Mysql“select * from”不返回所有行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆