0

Is there a PostgreSQL function which takes a string/text and returns true if the database exists, and false otherwise?

PostgresSQL v12+, based on default postgresql versions in Ubuntu 18.04, 20.04 & 22.04..

1
  • in psql you can use \l Commented Jul 4, 2022 at 9:31

1 Answer 1

3

There is no builtin method, but you can run a SELECT query to get that. You need to connect to some database, e.g. postgres

select exists (select * from pg_database where datname = 'the_name');
0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.