CREATE DATABASE cannot run inside a transaction block in pgadmin 4
NickName: Ask DateTime:2020-03-09T21:27:13

CREATE DATABASE cannot run inside a transaction block in pgadmin 4

I am triing to run a script in pgAdmin 4, but I get this error:

CREATE DATABASE cannot run inside a transaction block

And this is the script:

CREATE USER ky_auth WITH PASSWORD 'ky_auth';
COMMENT ON ROLE ky_auth IS 'KnowYourself Auth Database User';
CREATE DATABASE ky_auth WITH OWNER = ky_auth;
COMMENT ON DATABASE ky_auth IS 'KnowYourself Auth Database';

CREATE USER ky_pers WITH PASSWORD 'ky_pers';
COMMENT ON ROLE ky_pers IS 'KnowYourself Personal Database User';
CREATE DATABASE ky_pers WITH OWNER = ky_pers;
COMMENT ON DATABASE ky_pers IS 'KnowYourself Personal Database';

CREATE USER ky_oper WITH PASSWORD 'ky_oper';
COMMENT ON ROLE ky_oper IS 'KnowYourself Operational Database User';
CREATE DATABASE ky_oper WITH OWNER = ky_oper;
COMMENT ON DATABASE ky_oper IS 'KnowYourself Operational Database';

CREATE USER knowyourself_tests WITH PASSWORD 'ky_tests' CREATEDB;
COMMENT ON ROLE knowyourself_tests IS 'KnowYourself Integration Tests Database User';

So what I have to change?

Thank you

and if put this above the script:

SET AUTOCOMMIT = ON

Then I get this error:

 unrecognized configuration parameter "autocommit"

if I do this:

CREATE USER ky_auth WITH PASSWORD 'ky_auth';
COMMENT ON ROLE ky_auth IS 'KnowYourself Auth Database User';

then it succeeds. but then If I do this:


CREATE DATABASE ky_auth WITH OWNER = ky_auth;
COMMENT ON DATABASE ky_auth IS 'KnowYourself Auth Database';

I get this error:

ERROR:  CREATE DATABASE cannot run inside a transaction block

Copyright Notice:Content Author:「」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/60601569/create-database-cannot-run-inside-a-transaction-block-in-pgadmin-4

More about “CREATE DATABASE cannot run inside a transaction block in pgadmin 4” related questions

CREATE DATABASE cannot run inside a transaction block in pgadmin 4

I am triing to run a script in pgAdmin 4, but I get this error: CREATE DATABASE cannot run inside a transaction block And this is the script: CREATE USER ky_auth WITH PASSWORD 'ky_auth'; COMMENT...

Show Detail

ansible cannot execute SQL CREATE DATABASE CREATE DATABASE cannot run inside a transaction block

There are several entries that CREATE DATABASE cannot run inside a transaction block which give the answer autocommit needs to be on. However, they do not reference ansible which is what I was look...

Show Detail

CREATE DATABASE cannot run inside a transaction block

I am working on AWS server + PostgreSQL. When I execute a query for creating the database I get an error: CREATE DATABASE cannot run inside a transaction block I am working on Linux Ubuntu 12.04 ...

Show Detail

Error CREATE DATABASE cannot run inside a transaction block

I am trying to create a database from a Java application running in Micronaut framework using jOOQ. The code contextSupplier.get().createDatabaseIfNotExists(this.databaseName).execute(); with a

Show Detail

ERROR: CREATE DATABASE cannot run inside a transaction block SQL state: 25001 - Using PostgresSQL and pgAdmin 4

Hi guys I'm stuck on a problem for my first database on Postgres and I cannot find a solution, I tried to see if it was a matter of setting autocommit on but apparently from postgres 9.x it's an

Show Detail

postgresql: cannot run inside a transaction block

I am trying to run these commands together in SQLbox of phppgadmin CREATE DATABASE "ir-staging"; CREATE USER django WITH ENCRYPTED PASSWORD 'django'; GRANT ALL PRIVILEGES ON DATABASE &quo...

Show Detail

Liquibase: ERROR: CREATE DATABASE cannot run inside a transaction block

I am trying to create a db on PostgreSQL using liquibase. This is my dbchangelog file <?xml version="1.0" encoding="UTF-8"?> <databaseChangeLog xmlns="http://www.

Show Detail

error: ALTER TYPE ... ADD cannot run inside a transaction block

I am trying to add new type value to my existing types in PostgreSQL. But I get the following error error: ALTER TYPE ... ADD cannot run inside a transaction block The query I used to add a new...

Show Detail

REINDEX DATABASE cannot run inside a transaction block

I am using an old version of sqlalchemy (0.8) and I need to execute "REINDEX DATABASE <dbname>" on PostgreSQLql 9.4 by using sqlalchemy api. Initially I tried with: conn = pg_db.connect() ...

Show Detail

CREATE DATABASE inside transaction

According to postgresql docs; CREATE DATABASE cannot be executed inside a transaction block. Is there a technical reason for this?

Show Detail