Y
Y
yuki2020-10-11 10:55:13
PostgreSQL
yuki, 2020-10-11 10:55:13

How to add nextval to postgresql column?

I have a DNS schema and an objSklad table, it has an id_sklad column. There is also a sequence objSklad_id_sklad_seq that is bound to id_sklad. I have, when filling out the table

INSERT INTO "DNS"."objSklad" (city, region)
  VALUES ('Omsk', 'OmskObl');

An error pops up that id_sklad cannot be null, but I kind of attached the sequence to the column.
If you fill it in this way, then everything works.
INSERT INTO "DNS"."objSklad" (id_sklad, city, region)
  VALUES (nextval('"DNS"."objSklad_id_sklad_seq"'), 'Omsk', 'OmskObl');

How to add nextval to id_sklad?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question