How to create tables in Postgre with fields not null?

Asked

Viewed 140 times

2

good morning gentlemen,

I made my attempt to create my Postgre table this way:

CREATE TABLE categoria (
    codigo BIGSERIAL,
    nome VARCHAR(50) NOT NULL,
    PRIMARY KEY(codigo)
); 

Despite the countryside name be as not null it is allowing it to be entered null as you can see below;

Image 1

inserir a descrição da imagem aqui

proof of insertion:

inserir a descrição da imagem aqui

field description:

inserir a descrição da imagem aqui

Could it be that something was missing in the construction of the table for it to effect the not null in the field name?

  • We have no way of knowing, it is stating that it does not work and showing nothing that informs this, when, because, how it happens.

  • I just executed the same command here and it worked perfectly. Both columns as not null

  • Sorry for my posting, I just corrected, @Maniero could take a look now please?

  • @Rovannlinhalis is there any verification I can do to analyze why this is happening?

  • I could not reproduce the problem, did what you did and returned error: http://sqlfiddle.com/#! 17/947d4/1

  • 1

    Try: INSERT INTO categoria (codigo) values (7); to check if there will still be the insertion.

  • there was no = ERROR: null value in column "name" violates not-null Constraint please let me know what’s going on?

  • our weird @Maniero

Show 3 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.