{"id":2345,"date":"2025-03-09T16:02:55","date_gmt":"2025-03-09T09:02:55","guid":{"rendered":"https:\/\/www.pgtutorial.com\/?page_id=2345"},"modified":"2025-03-09T16:02:56","modified_gmt":"2025-03-09T09:02:56","slug":"postgresql-rename-database","status":"publish","type":"page","link":"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-rename-database\/","title":{"rendered":"PostgreSQL Rename Database"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: In this tutorial, you&#8217;ll learn the exact steps to rename a PostgreSQL database safely and effectively.<\/p>\n\n\n\n<p>Sometimes, you want to rename a PostgreSQL database due to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Standardizing name conventions.<\/li>\n\n\n\n<li>Correcting an existing name.<\/li>\n<\/ul>\n\n\n\n<p>PostgreSQL provides the&nbsp;<code>ALTER DATABASE<\/code>&nbsp;statement to make it simple to rename a database.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"prerequisites\" id='prerequisites'>Prerequisites <a href=\"#prerequisites\" class=\"anchor\" id=\"prerequisites\" title=\"Anchor for Prerequisites\">#<\/a><\/h2>\n\n\n\n<p>Before you start renaming a PostgreSQL database, ensure the following:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>You have a superuser or the owner of the database.<\/li>\n\n\n\n<li>There are no active connections to the database you want to rename.<\/li>\n\n\n\n<li>You have a backup of the database you want to rename in case something goes wrong.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"renaming-a-database-using-the-alter-database-statement\" id='renaming-a-database-using-the-alter-database-statement'>Renaming a Database Using the ALTER DATABASE Statement <a href=\"#renaming-a-database-using-the-alter-database-statement\" class=\"anchor\" id=\"renaming-a-database-using-the-alter-database-statement\" title=\"Anchor for Renaming a Database Using the ALTER DATABASE Statement\">#<\/a><\/h2>\n\n\n\n<p>Here are the steps for renaming a database:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-1-connect-to-postgresql\" id='step-1-connect-to-postgresql'>Step 1: Connect to PostgreSQL <a href=\"#step-1-connect-to-postgresql\" class=\"anchor\" id=\"step-1-connect-to-postgresql\" title=\"Anchor for Step 1: Connect to PostgreSQL\">#<\/a><\/h3>\n\n\n\n<p>Open your terminal and connect to the database you want to rename:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\">psql -U postgres -d target_db<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\" id=\"step-2-disconnect-active-connections\" id='step-2-disconnect-active-connections'>Step 2: Disconnect Active Connections <a href=\"#step-2-disconnect-active-connections\" class=\"anchor\" id=\"step-2-disconnect-active-connections\" title=\"Anchor for Step 2: Disconnect Active Connections\">#<\/a><\/h3>\n\n\n\n<p>Terminate all connections to the database by running the following statement:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">SELECT<\/span> pg_terminate_backend(pg_stat_activity.pid)\n<span class=\"hljs-keyword\">FROM<\/span> pg_stat_activity\n<span class=\"hljs-keyword\">WHERE<\/span> datname = <span class=\"hljs-string\">'target_db'<\/span> <span class=\"hljs-keyword\">AND<\/span> pid &lt;&gt; pg_backend_pid();<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Replace&nbsp;<code>target_db<\/code>&nbsp;with the actual name of the database you want to rename.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-3-rename-the-database\" id='step-3-rename-the-database'>Step 3: Rename the Database <a href=\"#step-3-rename-the-database\" class=\"anchor\" id=\"step-3-rename-the-database\" title=\"Anchor for Step 3: Rename the Database\">#<\/a><\/h3>\n\n\n\n<p>Run the following&nbsp;<code>ALTER DATABASE<\/code>&nbsp;command to rename the database:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">ALTER<\/span> <span class=\"hljs-keyword\">DATABASE<\/span> target_db\n<span class=\"hljs-keyword\">RENAME<\/span> <span class=\"hljs-keyword\">TO<\/span> new_db;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Replace&nbsp;<code>target_db<\/code>&nbsp;with the current name and&nbsp;<code>new_db<\/code>&nbsp;with the desired name.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-4-verify-the-change\" id='step-4-verify-the-change'>Step 4: Verify the Change <a href=\"#step-4-verify-the-change\" class=\"anchor\" id=\"step-4-verify-the-change\" title=\"Anchor for Step 4: Verify the Change\">#<\/a><\/h3>\n\n\n\n<p>Show the new database to confirm the changes:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\">\\l new_db<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id=\"renaming-a-database-example\" id='renaming-a-database-example'>Renaming a Database Example <a href=\"#renaming-a-database-example\" class=\"anchor\" id=\"renaming-a-database-example\" title=\"Anchor for Renaming a Database Example\">#<\/a><\/h2>\n\n\n\n<p>We&#8217;ll create a database called&nbsp;<code>acc<\/code>&nbsp;and rename it to&nbsp;<code>accounting<\/code>:<\/p>\n\n\n\n<p>First, connect to the local PostgreSQL server using&nbsp;<code>psql<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\">psql -U postgres<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Second, <a href=\"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-create-database\/\">create a new database<\/a> called\u00a0<code>acc<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">DATABASE<\/span> acc;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Third, switch the current database to&nbsp;<code>acc<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\">\\c acc<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Fourth, open a new session and connect to the&nbsp;<code>postgres<\/code>&nbsp;database:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\">psql -U postgres<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Fifth, rename the&nbsp;<code>acc<\/code>&nbsp;database to&nbsp;<code>accounting<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">ALTER<\/span> <span class=\"hljs-keyword\">DATABASE<\/span> acc\n<span class=\"hljs-keyword\">RENAME<\/span> <span class=\"hljs-keyword\">TO<\/span> accounting;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>PostgreSQL issued the following error:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\">ERROR: <span class=\"hljs-keyword\">current<\/span> <span class=\"hljs-keyword\">database<\/span> cannot be renamed<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The&nbsp;<code>acc<\/code>&nbsp;database may have active connections. Run the following command to check:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">SELECT<\/span> datname, pid, application_name, client_addr, client_port\n<span class=\"hljs-keyword\">FROM<\/span> pg_stat_activity <span class=\"hljs-keyword\">WHERE<\/span> datname = <span class=\"hljs-string\">'acc'<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>It shows one active connection.<\/p>\n\n\n\n<p>Sixth, terminate the active connection:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">SELECT<\/span> pg_terminate_backend(pg_stat_activity.pid)\n<span class=\"hljs-keyword\">FROM<\/span> pg_stat_activity\n<span class=\"hljs-keyword\">WHERE<\/span> datname = <span class=\"hljs-string\">'acc'<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Seventh, rerun the&nbsp;<code>ALTER DATABASE<\/code>&nbsp;statement to rename the&nbsp;<code>acc<\/code>&nbsp;database:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">ALTER<\/span> <span class=\"hljs-keyword\">DATABASE<\/span> acc\n<span class=\"hljs-keyword\">RENAME<\/span> <span class=\"hljs-keyword\">TO<\/span> accounting;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Finally, verify the changes:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-14\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\">\\l accounting<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-14\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id=\"summary\" id='summary'>Summary <a href=\"#summary\" class=\"anchor\" id=\"summary\" title=\"Anchor for Summary\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use the&nbsp;<code>ALTER DATABASE ... RENAME TO<\/code>&nbsp;statement to rename a database. After renaming the database, you should update all application configurations referencing the old name.<\/li>\n<\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful ?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"2345\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-rename-database\/\"\n\t\t\t\tdata-post-title=\"PostgreSQL Rename Database\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"2345\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-rename-database\/\"\n\t\t\t\tdata-post-title=\"PostgreSQL Rename Database\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you&#8217;ll learn the exact steps to rename a PostgreSQL database safely and effectively.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":2269,"menu_order":5,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-2345","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PostgreSQL Rename Database: A Step-by-Step Guide<\/title>\n<meta name=\"description\" content=\"In this tutorial, you&#039;ll learn the exact steps to rename a PostgreSQL database safely and effectively.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-rename-database\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PostgreSQL Rename Database: A Step-by-Step Guide\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you&#039;ll learn the exact steps to rename a PostgreSQL database safely and effectively.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-rename-database\/\" \/>\n<meta property=\"og:site_name\" content=\"PostgreSQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2025-03-09T09:02:56+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-database-administration\\\/postgresql-rename-database\\\/\",\"url\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-database-administration\\\/postgresql-rename-database\\\/\",\"name\":\"PostgreSQL Rename Database: A Step-by-Step Guide\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/#website\"},\"datePublished\":\"2025-03-09T09:02:55+00:00\",\"dateModified\":\"2025-03-09T09:02:56+00:00\",\"description\":\"In this tutorial, you'll learn the exact steps to rename a PostgreSQL database safely and effectively.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-database-administration\\\/postgresql-rename-database\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-database-administration\\\/postgresql-rename-database\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-database-administration\\\/postgresql-rename-database\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pgtutorial.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PostgreSQL Database Administration\",\"item\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-database-administration\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"PostgreSQL Rename Database\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/#website\",\"url\":\"https:\\\/\\\/www.pgtutorial.com\\\/\",\"name\":\"PostgreSQL Tutorial\",\"description\":\"Learn PostgreSQL from Scratch\",\"alternateName\":\"PostgreSQL\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.pgtutorial.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PostgreSQL Rename Database: A Step-by-Step Guide","description":"In this tutorial, you'll learn the exact steps to rename a PostgreSQL database safely and effectively.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-rename-database\/","og_locale":"en_US","og_type":"article","og_title":"PostgreSQL Rename Database: A Step-by-Step Guide","og_description":"In this tutorial, you'll learn the exact steps to rename a PostgreSQL database safely and effectively.","og_url":"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-rename-database\/","og_site_name":"PostgreSQL Tutorial","article_modified_time":"2025-03-09T09:02:56+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-rename-database\/","url":"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-rename-database\/","name":"PostgreSQL Rename Database: A Step-by-Step Guide","isPartOf":{"@id":"https:\/\/www.pgtutorial.com\/#website"},"datePublished":"2025-03-09T09:02:55+00:00","dateModified":"2025-03-09T09:02:56+00:00","description":"In this tutorial, you'll learn the exact steps to rename a PostgreSQL database safely and effectively.","breadcrumb":{"@id":"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-rename-database\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-rename-database\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-rename-database\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pgtutorial.com\/"},{"@type":"ListItem","position":2,"name":"PostgreSQL Database Administration","item":"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/"},{"@type":"ListItem","position":3,"name":"PostgreSQL Rename Database"}]},{"@type":"WebSite","@id":"https:\/\/www.pgtutorial.com\/#website","url":"https:\/\/www.pgtutorial.com\/","name":"PostgreSQL Tutorial","description":"Learn PostgreSQL from Scratch","alternateName":"PostgreSQL","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pgtutorial.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/2345","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/comments?post=2345"}],"version-history":[{"count":2,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/2345\/revisions"}],"predecessor-version":[{"id":2347,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/2345\/revisions\/2347"}],"up":[{"embeddable":true,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/2269"}],"wp:attachment":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/media?parent=2345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}