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
Generate the create table statement for a table in postgresql from linux commandline:
This statement outputs the table create sql statement for me:
pg_dump -U your_db_user_name your_database -t your_table_name --schema-only
Explanation:
pg_dump helps us get information about the database itself. -U stands for username. My pgadmin user has no password set, so I don't have to put in a password. The -t option means specify for one table. --schema-only means print only data about the table, and not the data in the table. Here is the exact command I use:
pg_dump -U pgadmin kurz_prod -t fact_stock_info --schema-only