Search Postgresql Archives

Re: unbale to list schema

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 17, 2024 at 1:46 PM Atul Kumar <akumar14871@xxxxxxxxx> wrote:
Hi,

I am not able to find any solution to list all schemas in all databases at once, to check the structure of the whole cluster.

As I need to give a few privileges to a user to all databases, their schemas and schemas' objects (tables sequences etc.).

Please let me know if there is any solution/ query that will serve the purpose.

Is this what you are looking for?

 #!/bin/bash
declare DbHost=<some_host>
declare DB=<some_db>
declare Schemas="select schema_name from information_schema.schemata
                 where schema_name not like 'pg_%' and schema_name != 'information_schema';"
for s in $(psql --host=$DbHost --dbname=$DB -AXtc "${Schemas}")
do
    pg_dump --dbname=$DB --schema-only --schema=${s} > schema_${DbHost}_${DB}_${s}.sql
done 

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux