1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

postgres create user only if not exists

Discussão em 'Outras Linguagens' iniciado por Stack, Janeiro 11, 2021.

  1. Stack

    Stack Membro Participativo

    I have few CREATE user as part of myquery.sql files and it contains few other queries as well

    my file looks like this

    CREATE USER myuser NOLOGIN;
    GRANT CONNECT on DATABSE myDataBase to myuser;
    GRANT USAGE ON SCHEAMA myschema to myuser;


    I have few queries like this in the same file, due to some reason I need to add new queries to same file, when execute the same file again I stuck with error user already exists, and does not reach to newly added query.

    also I checked there is no IF NOT EXISTS kind of help for CREATE USER in postgres.

    so how to add the check to create a USER only if not EXISTS.

    Continue reading...

Compartilhe esta Página