Duplicate entry '2147483647' for key 1

前端 未结 12 789
南笙
南笙 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: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

提交回复
热议问题