How to generate the statement CREATE TABLE for an existing table in postgreSQL

0 votes
I have created a table in postgreSQL.

How to get the create table statement for a table that is already existing in Postgres via commandline or SQL statement?
Feb 9 in Database by Vaani
• 5,040 points
114 views

1 answer to this question.

0 votes

Generate table creation statement for an existing table
Use command line tool:

pg_dump -t 'schema_name.table_name' --schema-only database_name
 

Use TablePlus GUI Tool:

Select the table that you want to replicate from the list in the left sidebar.
Switch to the Structure tab at the bottom, or use shortcut keys Cmd + Ctrl + ]
Click on the Definition button on the top bar.
You will notice the table creation statement to copy.

pg_dump

pg_dump — extract a PostgreSQL database into a script file or other archive file

pg_dump [connection-option...] [option...] [dbname]

answered Feb 9 by Neha
• 6,260 points

Related Questions In Database

0 votes
2 answers
0 votes
2 answers

How to select the nth row in a SQL database table?

SELECT * FROM ( SELECT ID, NAME, ROW_NUMBER() ...READ MORE

answered Apr 23, 2020 in Database by anand
• 140 points
15,386 views
0 votes
1 answer

How to create an excel file in android?

In Android, create Excel XLSX or XLS ...READ MORE

answered Apr 4 in Database by Edureka
• 9,320 points
26 views
0 votes
0 answers
0 votes
2 answers

Install postgreSQL on Ubuntu

Follow the below commands to install PostgreSQL (PSQL) ...READ MORE

answered Nov 12, 2020 in Database by Prachi
• 140 points
376 views
0 votes
1 answer

Access progrs prompt without switching accounts

Use the following to get the postgres prompt ...READ MORE

answered Mar 22, 2019 in Database by Mahi
296 views
0 votes
1 answer

Create new role - postgresql on ubuntu

If you are logged in as the postgres account, ...READ MORE

answered Mar 22, 2019 in Database by Danny
244 views
0 votes
1 answer
0 votes
1 answer

How to rename a column in a database table using SQL?

For SQL Server, use sp_rename USE AdventureWorks; GO EXEC sp_rename 'Customers.CustomerTerritory.TerritoryID', ...READ MORE

answered Feb 9 in Database by Neha
• 6,260 points
52 views
0 votes
1 answer

How to do version control for SQL Server database?

Not only can you compare objects at ...READ MORE

answered Feb 15 in Database by Neha
• 6,260 points
13 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP