我的数据库中有一行无法删除。我在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)
答案 0 :(得分:2)
它显然已被删除,但在某处你有一个upsert为gemini创建一个条目。了解价格,数量和时间戳如何变化。
我应该说错误的原因是INT的最大签名值为2147483647.您尝试插入更高值(2465337307)的尝试显然会被截断到最大值,在这种情况下是真的,您已经有一个gemini的条目,2147483647。尝试插入
INSERT INTO `trades` VALUES("gemini",2147483646,17317.010000,0.008923,1513178949);
使用你的python程序。