Granting user privilege to create/drop database of specific name
I have a PostgreSQL user named mydb_user who has been granted ownership of mydb_dev. mydb_user already has the privilege to drop the database, but I want him to be able to create the database again after deleting it. If possible, I'd like him to only be able to create a database with the same name (mydb_dev) again, but if necessary, I will settle for letting him create a database with any name.
Solution 1:
You want to grant the user role the CREATEDB
privilege.
The ability to drop the database is automatically granted to the DB owner, however you must have the CREATEDB
privilege to create new databases -- Note that this allows the user to create a database with any name...