Subject: Redo CREATE DATABASE

From: COURTAULT Francois <[email-masked]>
Date: Mon, 17 Nov 2025 09:59:21 +0000

THALES GROUP LIMITED DISTRIBUTION to email recipients

Hello everyone,

I am looking to an old document where we (I was not there at that time) setup a database.
Unfortunately, I was not able to find the CREATE DATABASE instruction used. It is not in any of our docs ☹
At https://www.postgresql.org/docs/17/sql-createdatabase.html we can see that a lot of options are available.

Do you know  if it is possible to retrieve the options we have set when we created the database ?

Best Regards.

---

From: Guillaume Lelarge <[email-masked]>
Date: Mon, 17 Nov 2025 11:16:20 +0100

Hi,

On 17/11/2025 10:59, COURTAULT Francois wrote:
> At https://www.postgresql.org/docs/17/sql-createdatabase.html <https:// 
> www.postgresql.org/docs/17/sql-createdatabase.html> we can see that a 
> lot of options are available.
> 

You can't retrieve the old options if they have been changed later. You 
can find the current ones with text tools like pg_restore, pg_dumpall, 
or graphical tools (such as pgAdmin).

Regards.

-- 
Guillaume Lelarge
Consultant
https://dalibo.com

---

From: Greg Sabino Mullane <[email-masked]>
Date: Mon, 17 Nov 2025 07:40:28 -0500

If you had log_statement set to something other than 'none', the create
database statement will appear in your database logs.

If you don't have it set, today would be a great day to set it to 'ddl'.

https://www.postgresql.org/docs/17/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-WHAT

Cheers,
Greg

--
Crunchy Data - https://www.crunchydata.com
Enterprise Postgres Software Products & Tech Support

---

From: Adrian Klaver <[email-masked]>
Date: Mon, 17 Nov 2025 07:52:14 -0800

> we created the database ?

Assuming the database is still in the cluster.

In psql have you tried:

\l+ <the_db_name>

Also

select * from pg_database where datname = <the_db_name>

They may not give you everything, but it will be a start.

-- 
Adrian Klaver
[email-masked]

---

From: Laurenz Albe <[email-masked]>
Date: Mon, 17 Nov 2025 16:59:01 +0100

On Mon, 2025-11-17 at 09:59 +0000, COURTAULT Francois wrote:
> Unfortunately, I was not able to find the CREATE DATABASE instruction used. It is not in any of our docs☹

What I recommend is a schema-only dump with the --create option:

  pg_dump --schema-only --create dbname

You will find CREATE DATABASE and perhaps ALTER DATABASE statements near the top that you
can use to create a copy of the database.  There will also be GRANT statements for the
database.

Yours,
Laurenz Albe