Skip to main content
added more options and info
Source Link
jbalk
  • 7.6k
  • 1
  • 18
  • 41

One way to do it, from the postgis side, is to add a new serial column and set it as the primary key:

alter table your_table add column pk serial primary key;

This will provide QGIS the next sequence value as the idpk when you add new features.

You can also alter your existing id column like this:

create sequence your_table_id_seq;
alter table your_table alter column id set default nextval('your_table_id_seq');
select max(id) + 1 from your_table; -- use this value in the next part
alter sequence your_table_id_seq 
  minvalue 100 -- change this number to the max(id) + 1 value
  start 100 -- also change this number
  restart 100 -- and this number

You might also need to make the id column the primary key:

alter table your_table add primary key (id);

One way to do it, from the postgis side, is to add a new serial column and set it as the primary key:

alter table your_table add column pk serial primary key;

This will provide QGIS the next sequence value as the id when you add new features.

One way to do it, from the postgis side, is to add a new serial column and set it as the primary key:

alter table your_table add column pk serial primary key;

This will provide QGIS the next sequence value as the pk when you add new features.

You can also alter your existing id column like this:

create sequence your_table_id_seq;
alter table your_table alter column id set default nextval('your_table_id_seq');
select max(id) + 1 from your_table; -- use this value in the next part
alter sequence your_table_id_seq 
  minvalue 100 -- change this number to the max(id) + 1 value
  start 100 -- also change this number
  restart 100 -- and this number

You might also need to make the id column the primary key:

alter table your_table add primary key (id);
Source Link
jbalk
  • 7.6k
  • 1
  • 18
  • 41

One way to do it, from the postgis side, is to add a new serial column and set it as the primary key:

alter table your_table add column pk serial primary key;

This will provide QGIS the next sequence value as the id when you add new features.