创建新的PostgreSQl数据库

创建新的PostgreSQl数据库,postgresql,liquibase-sql,Postgresql,Liquibase Sql,我正在尝试使用Liquibase创建一个新的PostgreSQL数据库。 我使用以下语法: <?xml version="1.0" encoding="UTF-8"?> <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

我正在尝试使用Liquibase创建一个新的PostgreSQL数据库。 我使用以下语法:

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd">

<changeSet id="23" author="pre_actions">
    <sqlFile dbms="postgresql" path="src\main\resources\liquibase\createDB.sql" />
</changeSet>

[错误]无法执行目标 org.liquibase:liquibase maven插件:3.6.3:on上的更新(默认cli) 项目cre\u角色\u架构:设置或运行Liquibase时出错: 更改集的迁移失败 src/main/resources/liquibase/createDB.xml::23::pre_actions:[错误]
原因:liquibase.exception.DatabaseException:错误:创建数据库 无法在事务块内运行[失败的SQL:--Create DB octopusdb[错误]创建数据库octopusdb所有者octopus]


--create database语句直接从psql开始工作正常

您可以尝试在PostgreSQL客户端(即psql)中运行
SET AUTOCOMMIT=ON
,我不确定标记更改集上的开关runInTransaction=“false”到底做了什么,但试一试。但如中所述,Liquibase不是创建数据库的正确工具。将属性runInTransaction=“false”添加到变更集确实允许创建数据库。谢谢你,特克利斯!