I drop not null
on primary key column, and it executes, after I check schema of table and there is not null
table:
-- auto-generated definition
create table warehouses
(
id_warehouse serial not null
constraint warehouse_pkey
primary key,
responsible_person varchar(30) not null
);
script to drop not null:
alter table warehouses
drop constraint warehouse_pkey;
alter table warehouses
alter id_warehouse drop not null;
alter table warehouses
add constraint warehouse_pkey
primary key (id_warehouse);
Per information here:
https://www.postgresql.org/docs/current/sql-createtable.html
PRIMARY KEY (column constraint)
The PRIMARY KEY constraint specifies that a column or columns of a table can contain only unique (non-duplicate), nonnull values. Only one primary key can be specified for a table, whether as a column constraint or a table constraint.
A column defined as PRIMARY KEY
will also have the NOT NULL
constraint set.