Sometimes, instead of back up and restore to a new db and wait your time if you only want to copy a database and put in the same server, you can use the following query:
CREATE DATABASE newdb WITH TEMPLATE originaldb OWNER dbuser;Note that this query only successfully if no sessions existing in originaldb. So, you can check originaldb sessions and kill them with this function pg_terminate_backend(procpid)
No comments:
Post a Comment