How to generate the “create table” sql statement for an existing table in postgreSQL

后端 未结 19 2048
花落未央
花落未央 2020-11-28 17:49

I have created a table in postgreSQL. I want to look at the SQL statement used to create the table but cannot figure it out.

How do I get the create table

19条回答
  •  星月不相逢
    2020-11-28 18:08

    This is the variation that works for me:

    pg_dump -U user_viktor -h localhost unit_test_database -t floorplanpreferences_table --schema-only

    In addition, if you're using schemas, you'll of course need to specify that as well:

    pg_dump -U user_viktor -h localhost unit_test_database -t "949766e0-e81e-11e3-b325-1cc1de32fcb6".floorplanpreferences_table --schema-only

    You will get an output that you can use to create the table again, just run that output in psql.

提交回复
热议问题