pgadmin III query

Started by Peter Kroonover 12 years ago9 messagesgeneral
Jump to latest
#1Peter Kroon
plakroon@gmail.com

When you click on a table in the "Object browser" you'll see in the "SQL
pane" the sql that is needed to create that table.

Which function can I call to get that SQL?

Best,
Peter

#2Ashesh Vashi
ashesh.vashi@enterprisedb.com
In reply to: Peter Kroon (#1)
Re: pgadmin III query

There is no ready available function to generate the reverse engineered
query.
pgAdmin III generates it from the metadata (table information) available.

On Fri, Dec 6, 2013 at 4:17 PM, Peter Kroon <plakroon@gmail.com> wrote:

When you click on a table in the "Object browser" you'll see in the "SQL
pane" the sql that is needed to create that table.

Which function can I call to get that SQL?

Best,
Peter

--
--

Thanks & Regards,

Ashesh Vashi
EnterpriseDB INDIA: Enterprise PostgreSQL Company<http://www.enterprisedb.com&gt;

*http://www.linkedin.com/in/asheshvashi*&lt;http://www.linkedin.com/in/asheshvashi&gt;

#3Jov
zhao6014@gmail.com
In reply to: Peter Kroon (#1)
Re: pgadmin III query

use pg_dump -s can get the DDL SQL.

jov
在 2013-12-6 下午6:50,"Peter Kroon" <plakroon@gmail.com>写道:

Show quoted text

When you click on a table in the "Object browser" you'll see in the "SQL
pane" the sql that is needed to create that table.

Which function can I call to get that SQL?

Best,
Peter

#4Ian Lawrence Barwick
barwick@gmail.com
In reply to: Peter Kroon (#1)
Re: pgadmin III query

2013/12/6 Peter Kroon <plakroon@gmail.com>:

When you click on a table in the "Object browser" you'll see in the "SQL
pane" the sql that is needed to create that table.

Which function can I call to get that SQL?

You can use the pg_dump command line function for this:

pg_dump -s -t name_of_table name_of_database

Regards

Ian Barwick

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#5Peter Kroon
plakroon@gmail.com
In reply to: Ian Lawrence Barwick (#4)
Re: pgadmin III query

Thanks, but i need a non command line option.

2013/12/6 Ian Lawrence Barwick <barwick@gmail.com>

Show quoted text

2013/12/6 Peter Kroon <plakroon@gmail.com>:

When you click on a table in the "Object browser" you'll see in the "SQL
pane" the sql that is needed to create that table.

Which function can I call to get that SQL?

You can use the pg_dump command line function for this:

pg_dump -s -t name_of_table name_of_database

Regards

Ian Barwick

#6Dinesh Kumar
dinesh.kumar@enterprisedb.com
In reply to: Peter Kroon (#5)
Re: pgadmin III query

Hi,

On Fri, Dec 6, 2013 at 4:34 PM, Peter Kroon <plakroon@gmail.com> wrote:

Thanks, but i need a non command line option.

We can do this with a function which is having the sql queries of pgAdmin
raised against the database.

=> Log all the queries by enabling "log_minduration_statement=0".
=> Do SELECT pg_reload_conf();
=> Do a refresh on a table of pgAdmin's browser.
=> Get all the queries what it has performed.
=> Create a custom function with those queries.

Regards,
Dinesh

Show quoted text

2013/12/6 Ian Lawrence Barwick <barwick@gmail.com>

2013/12/6 Peter Kroon <plakroon@gmail.com>:

When you click on a table in the "Object browser" you'll see in the "SQL
pane" the sql that is needed to create that table.

Which function can I call to get that SQL?

You can use the pg_dump command line function for this:

pg_dump -s -t name_of_table name_of_database

Regards

Ian Barwick

#7Dinesh Kumar
dinesh.kumar@enterprisedb.com
In reply to: Peter Kroon (#1)
Re: pgadmin III query

Hi Peter,

On Mon, Dec 9, 2013 at 7:03 PM, Peter Kroon <plakroon@gmail.com> wrote:

Hi Dinesh,

Get all the queries what it has performed.

How and where?
When I run "select * from pg_stat_activity" I get the same result with and
without "log_minduration_statement=0"

By setting this parameter log_min_duration_statement to 0, postgres will
log all the queries, in the pg_log file.

Hope the following steps helps you on this, and make sure you have enabled
the logging_collector.

1. Modify the above parameter on the required postgres cluster.

2. Do SELECT pg_reload_conf(); on the same machine.

3. And go to pg_log file location, and do tail -f current pg_log file.

4. Go to pgadmin, and refresh on any table.

5. Check the tail -f <pg_log>file output. There you will find all the sql
queries, which have been executed from pgAdmin.

6. Collect those queries, and make your own custom function with pl/pgsql
language.

Regards,
Dinesh

Show quoted text

Could you provide a more detailed step by step guide?

Best,
Peter

2013/12/9 Dinesh Kumar <dinesh.kumar@enterprisedb.com>

Hi,

On Fri, Dec 6, 2013 at 4:34 PM, Peter Kroon <plakroon@gmail.com> wrote:

Thanks, but i need a non command line option.

We can do this with a function which is having the sql queries of pgAdmin
raised against the database.

=> Log all the queries by enabling "log_minduration_statement=0".
=> Do SELECT pg_reload_conf();
=> Do a refresh on a table of pgAdmin's browser.
=> Get all the queries what it has performed.
=> Create a custom function with those queries.

Regards,
Dinesh

2013/12/6 Ian Lawrence Barwick <barwick@gmail.com>

2013/12/6 Peter Kroon <plakroon@gmail.com>:

When you click on a table in the "Object browser" you'll see in the

"SQL

pane" the sql that is needed to create that table.

Which function can I call to get that SQL?

You can use the pg_dump command line function for this:

pg_dump -s -t name_of_table name_of_database

Regards

Ian Barwick

#8Peter Kroon
plakroon@gmail.com
In reply to: Dinesh Kumar (#7)
Re: pgadmin III query

Hi Dinesh,

SELECT pg_reload_conf();
Did not do the job, I had to restart the server.
I managed to collect the queries and there are a lot of them to show the
SQL that is needed to create the given table.
Does postrgesql have any plan on making their own function for this?

Best,
Peter

2013/12/9 Dinesh Kumar <dinesh.kumar@enterprisedb.com>

Show quoted text

Hi Peter,

On Mon, Dec 9, 2013 at 7:03 PM, Peter Kroon <plakroon@gmail.com> wrote:

Hi Dinesh,

Get all the queries what it has performed.

How and where?
When I run "select * from pg_stat_activity" I get the same result with
and without "log_minduration_statement=0"

By setting this parameter log_min_duration_statement to 0, postgres will
log all the queries, in the pg_log file.

Hope the following steps helps you on this, and make sure you have enabled
the logging_collector.

1. Modify the above parameter on the required postgres cluster.

2. Do SELECT pg_reload_conf(); on the same machine.

3. And go to pg_log file location, and do tail -f current pg_log file.

4. Go to pgadmin, and refresh on any table.

5. Check the tail -f <pg_log>file output. There you will find all the sql
queries, which have been executed from pgAdmin.

6. Collect those queries, and make your own custom function with pl/pgsql
language.

Regards,
Dinesh

Could you provide a more detailed step by step guide?

Best,
Peter

2013/12/9 Dinesh Kumar <dinesh.kumar@enterprisedb.com>

Hi,

On Fri, Dec 6, 2013 at 4:34 PM, Peter Kroon <plakroon@gmail.com> wrote:

Thanks, but i need a non command line option.

We can do this with a function which is having the sql queries of
pgAdmin raised against the database.

=> Log all the queries by enabling "log_minduration_statement=0".
=> Do SELECT pg_reload_conf();
=> Do a refresh on a table of pgAdmin's browser.
=> Get all the queries what it has performed.
=> Create a custom function with those queries.

Regards,
Dinesh

2013/12/6 Ian Lawrence Barwick <barwick@gmail.com>

2013/12/6 Peter Kroon <plakroon@gmail.com>:

When you click on a table in the "Object browser" you'll see in the

"SQL

pane" the sql that is needed to create that table.

Which function can I call to get that SQL?

You can use the pg_dump command line function for this:

pg_dump -s -t name_of_table name_of_database

Regards

Ian Barwick

#9Dinesh Kumar
dinesh.kumar@enterprisedb.com
In reply to: Peter Kroon (#8)
Re: pgadmin III query

Hi Peter,

On Mon, Dec 9, 2013 at 7:52 PM, Peter Kroon <plakroon@gmail.com> wrote:

Hi Dinesh,

SELECT pg_reload_conf();
Did not do the job, I had to restart the server.
I managed to collect the queries and there are a lot of them to show the
SQL that is needed to create the given table.
Does postrgesql have any plan on making their own function for this?

I am not the right person to answer this question. Hope some will give you
answer for this.

I am not sure whether
it<http://vibhorkumar.wordpress.com/2010/11/01/pg_get_tabledef-function-in-postgres-plus/&gt;works
for you or not.

Regards,
Dinesh

Show quoted text

Best,
Peter

2013/12/9 Dinesh Kumar <dinesh.kumar@enterprisedb.com>

Hi Peter,

On Mon, Dec 9, 2013 at 7:03 PM, Peter Kroon <plakroon@gmail.com> wrote:

Hi Dinesh,

Get all the queries what it has performed.

How and where?
When I run "select * from pg_stat_activity" I get the same result with
and without "log_minduration_statement=0"

By setting this parameter log_min_duration_statement to 0, postgres will
log all the queries, in the pg_log file.

Hope the following steps helps you on this, and make sure you have
enabled the logging_collector.

1. Modify the above parameter on the required postgres cluster.

2. Do SELECT pg_reload_conf(); on the same machine.

3. And go to pg_log file location, and do tail -f current pg_log file.

4. Go to pgadmin, and refresh on any table.

5. Check the tail -f <pg_log>file output. There you will find all the sql
queries, which have been executed from pgAdmin.

6. Collect those queries, and make your own custom function with pl/pgsql
language.

Regards,
Dinesh

Could you provide a more detailed step by step guide?

Best,
Peter

2013/12/9 Dinesh Kumar <dinesh.kumar@enterprisedb.com>

Hi,

On Fri, Dec 6, 2013 at 4:34 PM, Peter Kroon <plakroon@gmail.com> wrote:

Thanks, but i need a non command line option.

We can do this with a function which is having the sql queries of
pgAdmin raised against the database.

=> Log all the queries by enabling "log_minduration_statement=0".
=> Do SELECT pg_reload_conf();
=> Do a refresh on a table of pgAdmin's browser.
=> Get all the queries what it has performed.
=> Create a custom function with those queries.

Regards,
Dinesh

2013/12/6 Ian Lawrence Barwick <barwick@gmail.com>

2013/12/6 Peter Kroon <plakroon@gmail.com>:

When you click on a table in the "Object browser" you'll see in the

"SQL

pane" the sql that is needed to create that table.

Which function can I call to get that SQL?

You can use the pg_dump command line function for this:

pg_dump -s -t name_of_table name_of_database

Regards

Ian Barwick