6

当我在 Sql Developer 中运行下面的脚本时,它会正确创建我的全局临时表,但是当我运行我的 liquibase 脚本时,它会因为“无效字符”而失败。任何人都知道为什么这会失败?

在 Sql Developer 中(作品)

 CREATE GLOBAL TEMPORARY TABLE TransactionsToMove(
              TransactionId NUMBER(38,0) NOT NULL,
              PRIMARY KEY (TransactionId))
              ON COMMIT DELETE ROWS;

Liquibase xml(失败并出现以下堆栈跟踪)

<changeSet id="createGlobalTemporaryTableForTransactionsMove" author="me" >
    <preConditions onFail="MARK_RAN">
        <not>
            <tableExists tableName="TransactionsToMove"/>
        </not>
    </preConditions>
    <sql splitStatements="false" endDelimiter=";"><![CDATA[              
      CREATE GLOBAL TEMPORARY TABLE TransactionsToMove(
          TransactionId NUMBER(38,0) NOT NULL,
          PRIMARY KEY (TransactionId))
          ON COMMIT DELETE ROWS;
    ]]>
    </sql>
</changeSet>

堆栈跟踪

    SEVERE 2013-11-14 09:10:liquibase: Error executing SQL CREATE GLOBAL TEMPORARY TABLE TransactionsToMove(
              TransactionId NUMBER(38,0) NOT NULL,
              PRIMARY KEY (TransactionId))
              ON COMMIT DELETE ROWS;
java.sql.SQLSyntaxErrorException: ORA-00911: invalid character

        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:445)
        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
        at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:879)
        at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:450)
        at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:192)
        at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
        at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:193)
        at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:1033)
        at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1329)
        at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1909)
        at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1871)
        at oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrapper.java:318)
        at liquibase.executor.jvm.JdbcExecutor$1ExecuteStatementCallback.doInStatement(JdbcExecutor.java:92)
        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)
        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:105)
        at liquibase.database.AbstractDatabase.execute(AbstractDatabase.java:1014)
        at liquibase.database.AbstractDatabase.executeStatements(AbstractDatabase.java:998)
        at liquibase.changelog.ChangeSet.execute(ChangeSet.java:317)
        at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:27)
        at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:58)
        at liquibase.Liquibase.update(Liquibase.java:113)
        at se.mypackage.exbo.database.liquibase.LiquibaseDatabaseManager.runChangelog(LiquibaseDatabaseManager.java:177)
        at se.mypackage.exbo.database.liquibase.LiquibaseDatabaseManager.create(LiquibaseDatabaseManager.java:145)
        at se.mypackage.exbo.database.DatabaseManager.dropAndCreate(DatabaseManager.java:349)
        at se.mypackage.exbo.database.DatabaseManager.main(DatabaseManager.java:720)
SEVERE 2013-11-14 09:10:liquibase: Change Set db/scripts/movetohistorical-oracleserver.xml::createGlobalTemporaryTableForTransactionsMove::marbe failed.  Error: Error executing SQL CREATE GLOBAL TEMPORARY TABLE TransactionsToMove(
              TransactionId NUMBER(38,0) NOT NULL,
              PRIMARY KEY (TransactionId))
              ON COMMIT DELETE ROWS;: ORA-00911: invalid character

liquibase.exception.DatabaseException: Error executing SQL CREATE GLOBAL TEMPORARY TABLE TransactionsToMove(
              TransactionId NUMBER(38,0) NOT NULL,
              PRIMARY KEY (TransactionId))
              ON COMMIT DELETE ROWS;: ORA-00911: invalid character

        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:62)
        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:105)
        at liquibase.database.AbstractDatabase.execute(AbstractDatabase.java:1014)
        at liquibase.database.AbstractDatabase.executeStatements(AbstractDatabase.java:998)
        at liquibase.changelog.ChangeSet.execute(ChangeSet.java:317)
        at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:27)
        at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:58)
        at liquibase.Liquibase.update(Liquibase.java:113)
        at se.mypackage.exbo.database.liquibase.LiquibaseDatabaseManager.runChangelog(LiquibaseDatabaseManager.java:177)
        at se.mypackage.exbo.database.liquibase.LiquibaseDatabaseManager.create(LiquibaseDatabaseManager.java:145)
        at se.mypackage.exbo.database.DatabaseManager.dropAndCreate(DatabaseManager.java:349)
        at se.mypackage.exbo.database.DatabaseManager.main(DatabaseManager.java:720)
Caused by: java.sql.SQLSyntaxErrorException: ORA-00911: invalid character

        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:445)
        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
        at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:879)
        at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:450)
        at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:192)
        at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
        at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:193)
        at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:1033)
        at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1329)
        at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1909)
        at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1871)
        at oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrapper.java:318)
        at liquibase.executor.jvm.JdbcExecutor$1ExecuteStatementCallback.doInStatement(JdbcExecutor.java:92)
        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)
        ... 11 more
INFO 2013-11-14 09:10:liquibase: Successfully released change log lock
Exception in thread "main" se.mypackage.exbo.database.DatabaseManagerException: Liquibase changelog update failed using changelog: db-main-create-13.4.xml, reason: Migration failed for change set db/scripts/movetohistorical-oraclese
     Reason: liquibase.exception.DatabaseException: Error executing SQL CREATE GLOBAL TEMPORARY TABLE TransactionsToMove(
              TransactionId NUMBER(38,0) NOT NULL,
              PRIMARY KEY (TransactionId))
              ON COMMIT DELETE ROWS;: ORA-00911: invalid character
:
          Caused By: Error executing SQL CREATE GLOBAL TEMPORARY TABLE TransactionsToMove(
              TransactionId NUMBER(38,0) NOT NULL,
              PRIMARY KEY (TransactionId))
              ON COMMIT DELETE ROWS;: ORA-00911: invalid character
:
          Caused By: ORA-00911: invalid character

        at se.mypackage.exbo.database.liquibase.LiquibaseDatabaseManager.runChangelog(LiquibaseDatabaseManager.java:180)
        at se.mypackage.exbo.database.liquibase.LiquibaseDatabaseManager.create(LiquibaseDatabaseManager.java:145)
        at se.mypackage.exbo.database.DatabaseManager.dropAndCreate(DatabaseManager.java:349)
        at se.mypackage.exbo.database.DatabaseManager.main(DatabaseManager.java:720)
Caused by: liquibase.exception.MigrationFailedException: Migration failed for change set db/scripts/movetohistorical-oracleserver.xml::createGlobalTemporaryTableForTransactionsMove::marbe:
     Reason: liquibase.exception.DatabaseException: Error executing SQL CREATE GLOBAL TEMPORARY TABLE TransactionsToMove(
              TransactionId NUMBER(38,0) NOT NULL,
              PRIMARY KEY (TransactionId))
              ON COMMIT DELETE ROWS;: ORA-00911: invalid character
:
          Caused By: Error executing SQL CREATE GLOBAL TEMPORARY TABLE TransactionsToMove(
              TransactionId NUMBER(38,0) NOT NULL,
              PRIMARY KEY (TransactionId))
              ON COMMIT DELETE ROWS;: ORA-00911: invalid character
:
          Caused By: ORA-00911: invalid character

        at liquibase.changelog.ChangeSet.execute(ChangeSet.java:347)
        at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:27)
        at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:58)
        at liquibase.Liquibase.update(Liquibase.java:113)
        at se.mypackage.exbo.database.liquibase.LiquibaseDatabaseManager.runChangelog(LiquibaseDatabaseManager.java:177)
        ... 3 more
Caused by: liquibase.exception.DatabaseException: Error executing SQL CREATE GLOBAL TEMPORARY TABLE TransactionsToMove(
              TransactionId NUMBER(38,0) NOT NULL,
              PRIMARY KEY (TransactionId))
              ON COMMIT DELETE ROWS;: ORA-00911: invalid character

        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:62)
        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:105)
        at liquibase.database.AbstractDatabase.execute(AbstractDatabase.java:1014)
        at liquibase.database.AbstractDatabase.executeStatements(AbstractDatabase.java:998)
        at liquibase.changelog.ChangeSet.execute(ChangeSet.java:317)
        ... 7 more
Caused by: java.sql.SQLSyntaxErrorException: ORA-00911: invalid character

        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:445)
        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
        at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:879)
        at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:450)
        at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:192)
        at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
        at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:193)
        at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:1033)
        at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1329)
        at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1909)
        at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1871)
        at oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrapper.java:318)
        at liquibase.executor.jvm.JdbcExecutor$1ExecuteStatementCallback.doInStatement(JdbcExecutor.java:92)
        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)
        ... 11 more
4

2 回答 2

10

分号是在客户端应用程序(如 Oracle SQL*Plus)中使用的命令终止符。

通过 Prepared Statement 或类似技术调用 db 命令时,通常不需要 is。

于 2013-11-14T09:16:42.967 回答
0

显然:从 Liquibase 中删除分号

Liquibase 不能正确使用分号。 SQL Developer 希望您使用分号。从一个到另一个复制粘贴语句会给你带来麻烦。

可以在网上找到一些解释尝试,例如:http: //forum.liquibase.org/topic/formatted-sql-enddelimiter-issue

值得注意的是,Oracle 本身对分号有不同的处理方式: SQL*Plus 命令不需要以分号结尾;而语句应该是。

于 2018-08-14T18:22:22.627 回答