PostgreSQL Null value in column violates not-null constraint
Null value in column violates not-null constraint in PL/pgSQL
Not-null constraint
The cause of error: Null value in column violates not-null constraint in PL/pgSQL.
Create Students table
CREATE TABLE test.students ( id numeric NOT NULL, first_name character varying(50) NOT NULL, last_name character varying(50) NOT NULL, entry_date timestamp without time zone DEFAULT now(), address_id numeric, CONSTRAINT studentss_pkey PRIMARY KEY (id) ); CREATE TABLE Query returned successfully in 506 msec.
Wrong insert
INSERT INTO test.students (id, first_name, last_name) VALUES (3, null, 'Evans');
ERROR: null value in column “first_name” violates not-null constraint
DETAIL: Failing row contains (3, null, Evans, 2017-02-18 08:33:08.125874, null).
Query returned successfully in 423 msec.
Correct insert
INSERT INTO test.students (id, first_name, last_name) VALUES (3, 'Sarah', 'Evans');
INSERT 0 1
Query returned successfully in 409 msec.