Create database from template and include comment

From: Peter Devoy <peter(at)3xe(dot)co(dot)uk>
To: "Psql_General (E-mail)" <pgsql-general(at)postgresql(dot)org>
Subject: Create database from template and include comment
Date: 2017-10-24 18:34:10
Message-ID: CABoFc_gt+LqTr+wf-yBgfgZ+gT4+d6SmoJRkOJdFK=szt_OY4A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all

If when creating a database I use another user-defined database as a
template I would like the option for the comment on the template database
to also exist for the new database. Am I correct in thinking there is no
feature for this, perhaps because the global nature of pg_shdescription?

For an example of the default behavior:

CREATE DATABASE test_comment_template;
COMMENT ON DATABASE test_comment_template IS 'hello world';

CREATE DATABASE test_comment WITH TEMPLATE test_comment_template;

SELECT oid, datname, shobj_description(oid, 'pg_database')
FROM pg_database
WHERE datname LIKE 'test_comment%';

oid | datname | shobj_description
--------+-----------------------+-------------------
828611 | test_comment_template | hello world
828612 | test_comment |

DROP DATABASE test_comment;
DROP DATABASE test_comment_template;

Kind regards

Peter

Browse pgsql-general by date

  From Date Subject
Next Message Don Seiler 2017-10-24 21:18:06 Re: Allow only certain query on replication slave
Previous Message Martin Moore 2017-10-24 15:44:43 Re: Postgres 9.6 fails to start on VMWare