Re: Database copy

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Kim Heckler <kim(dot)heckler(at)nationwide(dot)com>
Cc: "pgsql-novice(at)lists(dot)postgresql(dot)org" <pgsql-novice(at)lists(dot)postgresql(dot)org>
Subject: Re: Database copy
Date: 2021-06-03 17:32:02
Message-ID: 20210603173202.GB22019@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Thu, Jun 3, 2021 at 05:01:16PM +0000, Kim Heckler wrote:
> All,
>
>
>
> I have read in the CREATE DATABASE documentation:
>
>
>
> Although it is possible to copy a database other than template1 by specifying
> its name as the template, this is not (yet) intended as a general-purpose “COPY
> DATABASE” facility. The principal limitation is that no other sessions can be
> connected to the template database while it is being copied. CREATE DATABASE
> will fail if any other connection exists when it starts; otherwise, new
> connections to the template database are locked out until CREATE DATABASE
> completes. See Section 22.3 for more information.
>
>
>
> Can I safely use this on a regular basis to copy a database within the same
> instance/server? If not, I’ll use pg_dump and pg_restore to complete the ask.

Yes, you can use it as long as you accept its limitations of locking.
It is used all the time.

--
Bruce Momjian <bruce(at)momjian(dot)us> https://momjian.us
EDB https://enterprisedb.com

If only the physical world exists, free will is an illusion.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Jonas Gassenmeyer 2021-06-04 07:53:20 NOW() function in combination with SET timezone
Previous Message Kim Heckler 2021-06-03 17:01:16 Database copy