Thursday, May 16, 2024
HomeGolangIn PostgreSQL, I wish to verify for the existence of a database...

In PostgreSQL, I wish to verify for the existence of a database and consumer and carry out a department course of – Getting Assist


I wish to execute the next question if the database and consumer doesn’t exist.

CREATE DATABASE database;
CREATE ROLE consumer WITH LOGIN PASSWORD 'password';
REVOKE CONNECT ON DATABASE db1 FROM PUBLIC;
GRANT CONNECT ON DATABASE db1dev TO userbdev;

PostgreSQL doesn’t enable IF NOT EXSIST in CREATE DATABASE like MySQL does, so I wish to do the branching on the applying facet, is there a greater means?

Hello! There are three strategies to do it. After all you may put in and the consumer’s existence situation, and I’d keep away from this type of op between transaction statements.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments