pgsql psycopg2.errors.NotNullViolation: null value in column "id" violates not-null constraint错误解决


网上搜了很多资料,问题出现在一个地方,就是字段问题(integer),改为serial即可。

但是必须重新建表 ,如果不想重新建表,参考(本人没尝试过):https://stackoverflow.com/questions/23578427/changing-primary-key-int-type-to-serial

从pgsql中导出sql文件发现是这样:

 解决方案:

 重新建表(如果出现pk_test_a_id已经存在,改一下即可)

 create table info_xxx
(
    id serial,
        ........ , 
    constraint pk_test_a_id primary key(id)
);

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM