I have a PostGIS instance in which I'm attempting to use QGIS to create 3 different geometric tables (point, line, polygon) with identical fields.

I've created the point table, but there does not seem to be a way (as in ArcGIS) to import fields using another layer's fields as a template.

I've read this: Creating new PostGIS table with records + geometries from another table?

but I do not need to wholesale copy entire tables; I need to create new tables with different geometry types but which have the same set of fields/value types.

1 Answer 1


You can do it directly in Postgres.

use the create like command, and instruct to preserve the keys, constraints, default etc (but not foreign keys and triggers):

CREATE TABLE new_table_name ( LIKE old_table_name INCLUDING ALL);

Then modify the geometry type

ALTER TABLE new_table_name ALTER COLUMN geometry TYPE geometry(polygon,4326);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.