我的数据库中有一行无法删除。我在python中运行了这个SQL,得到了这个错误:
MariaDB [cryptotrader2]> INSERT INTO `trades` VALUES("gemini",2465337307,17317.010000,0.008923,1513178949);
ERROR 1062 (23000): Duplicate entry 'gemini-2147483647' for key 'PRIMARY'这很奇怪,因为我不会影响那个条目。我发现只有一行的exchange='gemini‘,我不能删除它,也不能添加exchange='gemini’的其他条目。或者至少不是来自我的python程序。正如您在下面看到的,我成功地进行了手动输入。我没有问题的条目与其他交换名称,它只是双子座。
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 84
Server version: 10.0.30-MariaDB-0+deb8u1 (Debian)
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [cryptotrader2]> select * from trades where exchange='gemini'
->
-> ;
+----------+------------+----------+------------+------------+
| exchange | trade_id | price | volume | timestamp |
+----------+------------+----------+------------+------------+
| gemini | 2147483647 | 17395.80 | 0.06573300 | 1513178007 |
+----------+------------+----------+------------+------------+
1 row in set (0.00 sec)
MariaDB [cryptotrader2]> delete from trades where exchange='gemini';
Query OK, 1 row affected (0.01 sec)
MariaDB [cryptotrader2]> select * from trades where exchange='gemini';
+----------+------------+----------+------------+------------+
| exchange | trade_id | price | volume | timestamp |
+----------+------------+----------+------------+------------+
| gemini | 2147483647 | 17385.33 | 0.07917300 | 1513178234 |
+----------+------------+----------+------------+------------+
1 row in set (0.00 sec)
MariaDB [cryptotrader2]> insert into trades values ('gemini',1234564560,17000,1,1513178235);
Query OK, 1 row affected (0.00 sec)
MariaDB [cryptotrader2]> select * from trades where exchange='gemini'; +----------+------------+----------+------------+------------+
| exchange | trade_id | price | volume | timestamp |
+----------+------------+----------+------------+------------+
| gemini | 1234564560 | 17000.00 | 1.00000000 | 1513178235 |
| gemini | 2147483647 | 17385.33 | 0.07917300 | 1513178234 |
+----------+------------+----------+------------+------------+
2 rows in set (0.01 sec)
MariaDB [cryptotrader2]> delete from trades where exchange='gemini'; Query OK, 2 rows affected (0.00 sec)
MariaDB [cryptotrader2]> select * from trades where exchange='gemini';
+----------+------------+----------+------------+------------+
| exchange | trade_id | price | volume | timestamp |
+----------+------------+----------+------------+------------+
| gemini | 2147483647 | 17390.16 | 0.87946700 | 1513178350 |
+----------+------------+----------+------------+------------+
1 row in set (0.00 sec)发布于 2017-12-14 00:48:33
它显然正在被删除,但在某个地方,您有一个upsert为gemini创建了一个条目。看看价格、成交量和时间戳是如何变化的。
我应该说,错误的原因是INT的最大有符号值为2147483647。您尝试插入一个更高的值(2465337307)的尝试显然被截断为最大值,在本例中是真的,您已经有一个针对gemini的条目,2147483647。尝试插入
INSERT INTO `trades` VALUES("gemini",2147483646,17317.010000,0.008923,1513178949); 使用您的python程序。
https://stackoverflow.com/questions/47798178
复制相似问题