查询1是
SELECT id,state,submission_id FROM document WHERE submission_id>=0;
+---------+-------+---------------+
| id | state | submission_id |
+---------+-------+---------------+
| 3000001 | -1 | 12345 |
+---------+-------+---------------+
1 row in set (0.00 sec)
显然,只有一条记录提交了submission_id> = 0。
查询2是
SELECT id,state,submission_id FROM document WHERE submission_id>=0 OR state=0 ORDER BY submission_id LIMIT 5;
ERROR 2013 (HY000): Lost connection to MySQL server during query
第三个问题是在我等待10分钟之后
SELECT * from document WHERE state = 0 OR submission_id> = 0 order by submission_id desc limit 5;
+----+-------+---------------+
| id | state | submission_id |
+----+-------+---------------+
| 1 | 1 | -1 |
| 2 | 1 | -1 |
| 3 | 1 | -1 |
| 4 | 1 | -1 |
| 5 | 1 | -1 |
+----+-------+---------------+
怎么了? id = 3000001项应该是第一个,对吗?
在我为“提交”列编制索引后会发生这种情况。无论如何要删除此列的索引?
供参考“描述文件”看起来像
+---------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| state | int(11) | YES | MUL | NULL | |
| submission_id | int(11) | YES | MUL | NULL | |
+---------------+--------------+------+-----+---------+----------------+
答案 0 :(得分:0)
以下是删除submission_id索引的方法
ALTER TABLE document DROP INDEX submission_id;
如果索引的名称不是submission_id,则可以通过以下方式找到它:
SHOW CREATE TABLE document\G
您将看到底部定义了索引的表定义。
您将看到索引的正确名称。
查找submission_id索引名称的另一种方法是:
SELECT index_name FROM information_schema.statistics
WHERE table_name='document'
AND column_name='submission_id';