1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[SQL] Gaps between primary key id in sql table

Discussão em 'Outras Linguagens' iniciado por Stack, Outubro 3, 2024 às 19:33.

  1. Stack

    Stack Membro Participativo

    I have a table which is:

    CREATE SEQUENCE id_seq;
    CREATE TABLE public."UserInfo"
    (
    id bigint NOT NULL DEFAULT nextval('id_seq'),
    phone text,
    password text,
    name text,
    surname text,
    middle_name text,
    email text,
    company text,
    title text,
    image_id text,
    CONSTRAINT "UserInfo_pkey" PRIMARY KEY (id),
    CONSTRAINT "UserInfo_image_id_key" UNIQUE (image_id),
    CONSTRAINT "UserInfo_phone_key" UNIQUE (phone)
    )
    WITH (
    OIDS=FALSE
    );
    ALTER SEQUENCE id_seq OWNED BY public."UserInfo".id;
    ALTER TABLE public."UserInfo"
    OWNER TO postgres;


    When I make bad request for insert like same value for unique column. "id" is increasing... Here is bad id request;

    ERROR: null value in column "id" violates not-null constraint
    DETAIL: Failing row contains (null, 9921455867, mg123209, name, surname, , namesurname@xxx.com, Company Name, Title Of Person, 123asd).
    ********** Error **********


    Here is my table result ;

    1;"1234477867";"qweff";"Name";"Surname";"''";"namesurname@qwe.com";"Company";"Title";"qwer1234"
    4;"5466477868";"1235dsf";"Name";"Surname";"''";"banesyrna@pwqe.com";"Company";"Title";"qwer1235"
    6;"5051377828";"asd123";"Name";"Surname";"''";"qweg@sdcv.com";"Company";"Title";"qwesr1235"


    Please help me how I can solve this issue, I want order like 1,2,3.. sequential..

    Continue reading...

Compartilhe esta Página