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)
);

 

 

posted @ 2020-06-30 14:42  想扣篮的小矮子  阅读(9844)  评论(0编辑  收藏  举报