美文网首页
(psycopg2.IntegrityError) duplic

(psycopg2.IntegrityError) duplic

作者: 西北望高楼 | 来源:发表于2018-06-20 14:19 被阅读39次

    插入数据时遇到上述标题错误,发现是nextval error.

    # 查看表最大id
    SELECT MAX(id) FROM area;
    -----------------------------------------------
     max 
    -----
     630
    (1 row)
    ------------------------------------------------
    
    # 查看该表nextval
    SELECT nextval('area_id_seq');
    ------------------------------------------------
     max 
    -----
     630
    (1 row)
    ------------------------------------------------
    
    # 执行修改序列
    SELECT setval('area_id_seq', (SELECT MAX(id) FROM area)+1);
    ------------------------------------------------
     setval 
    --------
        631
    (1 row)
    
    ------------------------------------------------
    

    相关文章

      网友评论

          本文标题:(psycopg2.IntegrityError) duplic

          本文链接:https://www.haomeiwen.com/subject/iuqxyftx.html