Reading list Switch to dark mode

    How to fix missing sequence in PostgreSQL

    Updated 15 April 2017

    Sequences objects are commonly used to generate unique numbers for tables.

    In this blog i will demonstrate how to fix missing sequence in PostgreSQL. Actually when we upgrade our table from older to new version then sometimes we face missing sequence issue. Below steps will help you to fix sequence missing issue.

    For example test_webkul_id_seq sequence table is missing from your table(“test_webkul“). You can also check your sequence table from your table,

    \d+ test_webkul;

    id  | integer   | not null default nextval(‘test_webkul_id_seq’::regclass) | plain    |              |

    In order to fix missing sequence issue create sequence table by running in below command in your postgres terminal,

    Searching for an experienced
    Odoo Company ?
    Find out More
    CREATE SEQUENCE test_webkul_id_seq;

    Then set your table’s next sequence by running below command. This step is necessary only if some data is already present in your table. In case you forgot to run below command then sequence of table will start from 1.

    SELECT setval('test_webkul_id_seq', 2500, true);

    In above command,

    • “test_webkul_id_seq” is regclass.
    • “2500” is next sequence of table.
    • true is_called flag.

    Hopefully that blog will be helpful for you to fix issue!!

     

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    Be the first to comment.

    Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home