skip to Main Content

I am creating a table in Postgresql, this DDL is the result of a script that I am making to compare bancos.

CREATE TABLE projeto_modelo.exemplo_fk1 
(
    id SERIAL NOT NULL,
    nome varchar(30) NOT NULL,
    criado_em timestamp NOT NULL,
    id_exmp_fk2 int4 NOT NULL,

    CONSTRAINT exemplo_fk1_id_exmp_fk2_fkey 
        FOREIGN KEY (id_exmp_fk2) 
        REFERENCES projeto_modelo.exemplo_fk2(id),
    PRIMARY KEY(id)
);

The problem is when a check in DBeaver the specifications of my table. DBeaver recommends:

CREATE TABLE projeto_modelo.exemplo_fk1 
(
    id serial4 NOT NULL,
    nome varchar(30) NOT NULL,
    criado_em timestamp NOT NULL,
    id_exmp_fk2 int4 NOT NULL
);

And when I check constraints nothing appears.

I expected an explanation for this.

2

Answers


  1. Chosen as BEST ANSWER

    I solved this problem in the DBeaver graphical interface, I just updated the table and when I went to check again, the two constraints created were there.


  2. I have solved this problem by creating sequence

    CREATE SEQUENCE seq 
    START WITH 1
    INCREMENT BY 1
    MINVALUE 1;
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search