clear markdown compare help donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 497144 fiddles created (9372 in the last week).

create table items (item_id serial, name varchar(10), item_group int); create table items_ver (id serial, item_id int, name varchar(10), item_group int); insert into items(name,item_group) values ('foo',10),('bar',10); select * from items;
2 rows affected
item_id name item_group
1 foo 10
2 bar 10
 hidden batch(es)


insert into items_ver select * from items where item_id=2;
ERROR: column "item_id" is of type integer but expression is of type character varying LINE 2: select * from items where item_id=2; ^ HINT: You will need to rewrite or cast the expression.
 hidden batch(es)


insert into items_ver(item_id, name, item_group) select * from items where item_id=2;
1 rows affected
 hidden batch(es)


insert into items_ver (item_id, name, item_group) select item_id, name, item_group from items where item_id=2;
1 rows affected
 hidden batch(es)