【发布时间】:2020-06-11 06:02:43
【问题描述】:
我在 Postgresql 中有 2 个具有相同架构的表,唯一的区别是其中一个表 id 字段是 bigint 类型。我需要填充数据的表的架构如下所示:
create table test_int_table(
id int,
description text,
hash_code int
);
我需要将带有 bigint id 的 test_table 中的数据复制到 public.test_int_table。并且应该过滤掉一些大于 id 范围的值。如何在不对范围进行硬编码的情况下跟踪这些值? 我可以做这样的事情,但我想构建更通用的解决方案:
insert into test_int_table
select * from test_table as test
where test.id not between 2147483647 and 9223372036854775808
泛型是指对列名及其数量没有限制。因此,以防万一,我在其他表中有多个 bigint 类型的列,我如何一般地过滤它们的所有列值(不指定列名)?
【问题讨论】:
标签: postgresql int bigint