Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6768017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:01:18+00:00 2026-05-26T15:01:18+00:00

I know there are two ways of making a copy of a database. One

  • 0

I know there are two ways of making a copy of a database.

One is to export the database as a giant SQL file, then load it as a separate database:

pg_dump <database> | psql <new database>

Another way is to pass the database name as a template to a database creation argument:

createdb -T <database> <new database>

What is the difference between these two methods, if any?
Are there any benefits of using one over another, such as performance?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:01:19+00:00Added an answer on May 26, 2026 at 3:01 pm

    According to the current docs

    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.

    Apart from that mild warning, which goes back to at least version 8.2, you can make certain kinds of changes by using createdb–things like changing collation, encoding, etc. (Within limits.)

    Personally, I’d have a hard time justifying the use of createdb, which takes a full database lock, to copy a production database.

    I think the other main difference is that “dump and load” is a fully supported way of copying a database. Also, you can carry a copy of the dump to an isolated development computer for testing if you need to. (The createdb utility has to have access to both the source and the target at the same time.) But I have not used createdb to make copies, so I could be wrong.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As far as I know, there are two ways to create a local database
As far as I know there are two ways to avoid ConcurrentModificationException while one
I know there are two ways, [self.navigationController pushViewController:siteViewController animated:YES]; [self presentModalViewController:anotherViewController animated:YES]; However, those
As far as I know (which is very little) , there are two ways,
Java question: As far as I know, there are two ways to check inside
As far as I know there are two ways to create local variables in
There are two ways that I know that you can fetch results in Rails
As most people know there are at least two (easy) ways to findout if
From my research I know there are two ways of using AspectJ. First is
In C++, i know there are two ways to overload. We can overload it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.