If you have a situation like me, then you can accomplish this a whole lot easier
Step 1: Get a good set of data, including the key field values(in my case, the problem was that the primary key could not be synced with two other tables properly)
Step 2: Use the SSMS ability to create a Drop and Create Table of the one you need to create. Also, make sure that ...
You have 2 options:
Before insert trigger to set person_id column with some sequence.
Set default value to sequence next value. Example is below.
create table t1 (id int primary key , x int);
insert into t1 values (1,1);
create sequence t1_Seq start with 2;
alter table t1 alter column id set default nextval('t1_seq');
insert into t1 (x) values (2);
If that is too much boilerplate code, then create a function that does the job:
create or replace function make_serial(p_table_schema text, p_table_name text, p_column_name text)
l_seq_name := concat(p_table_name, '_', p_column_name, '_seq');
l_full_name := ...