I have a PostgreSQL database with lots of tables of the same structure, 36 columns in total:
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)
)
In many instances I will have to insert records from another table with the same structure:
INSERT INTO some_schema.some_table (col2,col3...col35)
SELECT col2,col3...col35
FROM some_schema.another_table_with_same_structure;
Is there a way of doing this without having to list all columns that don't have a default value? I think I can use DEFAULT VALUES
somehow but I can't get the syntax right based on the documentation.