Copy table structure into new table

前端 未结 5 562
予麋鹿
予麋鹿 2020-12-07 14:30

Is there a way to copy the structure of a table into a new table, without data, including all keys and constraints?

5条回答
  •  生来不讨喜
    2020-12-07 14:35

    How about

    CREATE TABLE sample_table_copy AS (SELECT * FROM sample_table WHERE 1 = 2)
    

    postgresql.org answer

提交回复
热议问题