From: | Ron Johnson <ronljohnsonjr(at)gmail(dot)com> |
---|---|
To: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: unbale to list schema |
Date: | 2024-01-22 19:04:21 |
Message-ID: | CANzqJaC+5O1mS8bKhP_qNkGFEyRBiwS0dc2hS+Xsfhx2HGq3Bw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, Jan 17, 2024 at 1:46 PM Atul Kumar <akumar14871(at)gmail(dot)com> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Rob Sargent | 2024-01-22 23:38:20 | Re: Mimic ALIAS in Postgresql? |
Previous Message | Amit Sharma | 2024-01-22 17:43:58 | Disk Groups/Storage Management for a Large Database in PostgreSQL |