I need to insert some data from one table to another in Postgresql. Schema of the table I need to fill with data looks like this:
create table public.test_int_table(
id int,
description text,
hash_code int
);
The issue is that id column in another table is of bigint type. So when I try to insert biting data into int column I get an exception:
insert into public.test_int_table
select * from public.test_table
SQL Error [22003]: ERROR: integer out of range
How can I trim bigint data for insert in Postgresql? Usual cast operator seems to work only for upcasting (from int to bigint and not otherwise). Id it not a constantly increasing value and it fits into int in most of the cases so I don’t really care about loosing precision here.
intcolumns asbiginttype inpublic.test_int_tabletable ?