Duplicate entry '2147483647' for key 1

前端 未结 12 667
南笙
南笙 2020-12-18 21:41

Strange problem I can\'t seem to get my head around. I have a table in a MySQL database with the following structure...

    CREATE TABLE IF NOT EXISTS `tblb         


        
相关标签:
12条回答
  • 2020-12-18 22:17

    2147483647 is the largest int value for mysql. Just change the type from int to bigint.

    0 讨论(0)
  • 2020-12-18 22:21

    signed and unsigned issue

    alter table tblbaseprices
    modify column site_id int(10) unsigned NOT NULL;
    

    reference - http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html

    • make sure unsigned for foreign key (in this case could be the site_id)
    • it could be caused by trigger,
    • there is no int(11), the max it can go is int(10)
    • there is no need to allow negative value for ID
    • to be consistently using same data type for primary key
    0 讨论(0)
  • 2020-12-18 22:24

    With you code I got this error - Unknown column 'base_price_4a' in 'field list'. It means that you are trying to insert into another table (maybe in another schema), and that table has primary key INT and AUTO_INCREMENT=2147483647.

    0 讨论(0)
  • 2020-12-18 22:24

    you've hit the 32-bit integer limit, thus preventing the auto increment from incrementing. switching your pk to bigint with a higher column length should fix the issue.

    Also, if your PK is never going to be negative, switching to an unsigned int should give you more space.

    0 讨论(0)
  • 2020-12-18 22:29

    it's a database issue. check your phpmyadmin > your DB > structure, your primary key should be setted in "bigint", not just "int"

    0 讨论(0)
  • 2020-12-18 22:30

    Duplicate entry '57147-2147483647' for key 'app_user' [ INSERT INTO user_lookup (user_id, app_id, app_user_id, special_offers, ip_address) VALUES ('2426569', '57147', '4009116545', 1, 1854489853) ]

    0 讨论(0)
提交回复
热议问题