我有一个 PostgreSQL 数据库,其中有很多相同结构的表,总共 36 列:
CREATE TABLE some_schema.some_table (
id integer NOT NULL DEFAULT nextval('some_schema.id_seq'::regclass),
col2,
col3,
col4,
[...],
col35,
mi_prinx integer NOT NULL DEFAULT nextval('some_schema.mi_prinx_seq'::regclass),
CONSTRAINT some_table_pkey PRIMARY KEY (mi_prinx)
)
Run Code Online (Sandbox Code Playgroud)
在许多情况下,我必须从具有相同结构的另一个表中插入记录:
INSERT INTO some_schema.some_table (col2,col3...col35)
SELECT col2,col3...col35
FROM some_schema.another_table_with_same_structure;
Run Code Online (Sandbox Code Playgroud)
有没有一种方法可以做到这一点,而不必列出所有没有默认值的列?我想我可以以某种方式使用,但我无法根据文档DEFAULT VALUES
获得正确的语法。