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

0 votes
How do I get the create table SQL statement for an existing table in Postgres via commandline or SQL statement?
Jun 19, 2022 in Others by polo
• 1,480 points
550 views

1 answer to this question.

0 votes

Create a table for a demo:

CREATE TABLE your_table(
    thekey   integer NOT NULL,  
    ticker   character varying(10) NOT NULL,
    date_val date,
    open_val numeric(10,4) NOT NULL
); 

pg_dump manual, can output the table create psql statement:

pg_dump -U your_user your_database -t your_table --schema-only

Which prints:

-- pre-requisite database and table configuration omitted
CREATE TABLE your_table (
    thekey integer NOT NULL, 
    ticker character varying(10) NOT NULL, 
    date_val date,  
    open_val numeric(10,4) NOT NULL 
); 
-- post-requisite database and table configuration omitted
  
answered Jun 20, 2022 by nisha
• 2,210 points

Related Questions In Others

0 votes
1 answer

How to create arrow buttons in Excel to scroll the table left and right?

Ctrl-shift-home goes to the upper-left of all ...READ MORE

answered Mar 26, 2023 in Others by Kithuzzz
• 38,000 points
871 views
0 votes
1 answer

How to create an Icon Button in Flutter?

Hi@akhtar, To create an Icon Button in Flutter, ...READ MORE

answered Jul 24, 2020 in Others by MD
• 95,460 points
1,084 views
0 votes
1 answer

How to create an input field in Flutter?

Hi@akhtar, There are different ways to create an ...READ MORE

answered Aug 9, 2020 in Others by MD
• 95,460 points
1,459 views
0 votes
1 answer

How to create an Alert Button in Flutter?

Hi@akhtar, You can do this with the help ...READ MORE

answered Sep 3, 2020 in Others by MD
• 95,460 points
805 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to save a new sheet in an existing excel file, using Pandas?

import pandas as pd import numpy as np path ...READ MORE

answered Dec 10, 2022 in Others by narikkadan
• 63,600 points
7,640 views
0 votes
1 answer

How to multi level sort an array in excel, using formulas? I am aware about the way, using SORT button on DATA tab

Use SORTBY, e.g. =SORTBY(A2:B5,A2:A5,1,B2:B5,1) Or simply&nb ...READ MORE

answered Jan 22, 2023 in Others by narikkadan
• 63,600 points
590 views
0 votes
1 answer

How to prepare an APK for the Amazon Android App Store

you should use zipalign during every build, ...READ MORE

answered Jun 1, 2022 in Others by nisha
• 2,210 points
661 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP