Re: Truncate data from whole cluster

Поиск
Список
Период
Сортировка
Искать
От
hubert depesz lubaczewski
Тема
Re: Truncate data from whole cluster
Дата
Msg-id
ZYLArRMPsNu3ZooU@depesz.com
Ответ на
Список
Дерево обсуждения
Truncate data from whole cluster Rajesh Kumar <rajeshkumar.dba09@gmail.com>
Re: Truncate data from whole cluster hubert depesz lubaczewski <depesz@depesz.com>
AW: Truncate data from whole cluster "Dischner, Anton" <Anton.Dischner@med.uni-muenchen.de>
Re: AW: Truncate data from whole cluster hubert depesz lubaczewski <depesz@depesz.com>
Re: AW: Truncate data from whole cluster Rajesh Kumar <rajeshkumar.dba09@gmail.com>
On Wed, Dec 20, 2023 at 02:35:52PM +0530, Rajesh Kumar wrote:
> Hi all,
> 
> I am using postgres 15.2. one leader and one replica. I have multiple dbs
> and multiple tables. I want to keep definitions and only want to delete
> 'data only' from all dbs and tables.
> 
> Any command to do that instead of truncating all tables one by one?

No such command exists. For starters, no command in SQL can do stuff in
other databases than the one you are connected to.

You can write a simple one-liner that will do it, in your shell.
shouldn't be really complex - get list of dbs, and in each db connect
with psql and truncate all tables. basically: `psql | xargs psql`

depesz


В списке pgsql-admin по дате отправления
От: Rajesh Kumar
Дата:
От: Dischner, Anton
Дата:
FAQ