У нас есть простой тестовый пример создания представления в командной строке Liquibase 3.6.1:
Мы пытаемся понять, как устранить ошибку:
ORA-00933: команда SQL неправильно завершена
Мы попытались
<sql>
<createview>
Ниже приведен простой тестовый пример.
Вот список изменений:
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<changeSet author="jim" id="test1">
<createView viewName="VIEW_TEST" replaceIfExists="true" >
select table_name FROM user_tables ORDER BY table_name;
</createView>
</changeSet>
</databaseChangeLog>
Команда
time ./liquibase --changeLogFile=../changelog/test.xml --url=jdbc:oracle:thin:@//localhost:1521/ORCL --username "sys as sysdba" --password oracle --logLevel debug update
Мы всегда получаем это исключение: (К вашему сведению, мы также попробовали как <sql>
тот же результат)
➜ liquibase-3.6.1 time ./liquibase --changeLogFile=../changelog/test.xml --url=jdbc:oracle:thin:@//localhost:1521/ORCL --username "sys as sysdba" --password oracle --logLevel debug update
Starting Liquibase at Mon, 04 Jun 2018 12:52:44 PDT (version 3.6.1 built at 2018-04-11 08:41:04)
**Unexpected error running Liquibase: ORA-00933: SQL command not properly ended**
[Failed SQL: CREATE OR REPLACE VIEW SYS.VIEW_TEST AS select table_name FROM user_tables ORDER BY table_name;]
liquibase.exception.MigrationFailedException: Migration failed for change set ../changelog/test.xml::test1::jim:
Reason: liquibase.exception.DatabaseException: ORA-00933: SQL command not properly ended
**[Failed SQL: CREATE OR REPLACE VIEW SYS.VIEW_TEST AS select table_name FROM user_tables ORDER BY table_name;]**
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:637)
at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:53)
at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:78)
at liquibase.Liquibase.update(Liquibase.java:202)
at liquibase.Liquibase.update(Liquibase.java:179)
at liquibase.integration.commandline.Main.doMigration(Main.java:1205)
at liquibase.integration.commandline.Main.run(Main.java:191)
at liquibase.integration.commandline.Main.main(Main.java:129)
Caused by: liquibase.exception.DatabaseException: ORA-00933: SQL command not properly ended
[Failed SQL: CREATE OR REPLACE VIEW SYS.VIEW_TEST AS select table_name FROM user_tables ORDER BY table_name;]
at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:356)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:57)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:125)
at liquibase.database.AbstractJdbcDatabase.execute(AbstractJdbcDatabase.java:1229)
at liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1211)
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:600)
... 7 common frames omitted
**Caused by: java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended**
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:450)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:399)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1017)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:655)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:249)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:566)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:202)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:45)
at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:933)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1075)
at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1718)
at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1678)
at oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrapper.java:332)
at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:352)
... 12 common frames omitted
For more information, please use the --logLevel flag
./liquibase --changeLogFile=../changelog/test.xml --username "sys as sysdba" 4.61s user 0.27s system 238% cpu 2.048 total