<small id='QinVj'></small><noframes id='QinVj'>

      <bdo id='QinVj'></bdo><ul id='QinVj'></ul>

    1. <i id='QinVj'><tr id='QinVj'><dt id='QinVj'><q id='QinVj'><span id='QinVj'><b id='QinVj'><form id='QinVj'><ins id='QinVj'></ins><ul id='QinVj'></ul><sub id='QinVj'></sub></form><legend id='QinVj'></legend><bdo id='QinVj'><pre id='QinVj'><center id='QinVj'></center></pre></bdo></b><th id='QinVj'></th></span></q></dt></tr></i><div id='QinVj'><tfoot id='QinVj'></tfoot><dl id='QinVj'><fieldset id='QinVj'></fieldset></dl></div>
      <tfoot id='QinVj'></tfoot>

      <legend id='QinVj'><style id='QinVj'><dir id='QinVj'><q id='QinVj'></q></dir></style></legend>

    2. 在删除不存在的序列、创建现有用户时防止出错

      时间:2023-11-02
      <i id='0Jgxp'><tr id='0Jgxp'><dt id='0Jgxp'><q id='0Jgxp'><span id='0Jgxp'><b id='0Jgxp'><form id='0Jgxp'><ins id='0Jgxp'></ins><ul id='0Jgxp'></ul><sub id='0Jgxp'></sub></form><legend id='0Jgxp'></legend><bdo id='0Jgxp'><pre id='0Jgxp'><center id='0Jgxp'></center></pre></bdo></b><th id='0Jgxp'></th></span></q></dt></tr></i><div id='0Jgxp'><tfoot id='0Jgxp'></tfoot><dl id='0Jgxp'><fieldset id='0Jgxp'></fieldset></dl></div>

            <bdo id='0Jgxp'></bdo><ul id='0Jgxp'></ul>

            <small id='0Jgxp'></small><noframes id='0Jgxp'>

            <tfoot id='0Jgxp'></tfoot>
                <tbody id='0Jgxp'></tbody>
              <legend id='0Jgxp'><style id='0Jgxp'><dir id='0Jgxp'><q id='0Jgxp'></q></dir></style></legend>
              • 本文介绍了在删除不存在的序列、创建现有用户时防止出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一堆用于创建/删除序列、用户和其他对象的 sql 脚本.我正在通过 liquibase 运行这些脚本,但它们失败了,因为当我尝试删除不存在的序列或创建现有用户时,oracle 会抱怨.

                I have a bunch of sql scripts that create / drop sequences, users and other objects. I'm running these scripts through liquibase, but they fail because oracle complains when I try to drop a non existing sequence, or create an existing user.

                有没有oracle方法来防止错误发生?

                Is there an oracle way to prevent errors from happening?

                类似的东西

                如果不存在则创建用户/序列

                Create User / Sequence if not exists

                删除用户/安全如果存在

                Drop User/ Secuence if exists

                据我所知,我有以下选择:

                As far as I know, I have these options:

                • 编写 plsql 脚本
                • 使用 liquibase 上下文.
                • 使用 liquibase 前提条件,但这意味着工作量太大.

                任何想法/想法将不胜感激.

                Any thoughts / ideas will be greatly appreciated.

                推荐答案

                Liquibase 有一个 failOnError 属性,您可以在包含可能失败的调用的 changeSet 上将其设置为 false.

                Liquibase has a failOnError attribute you can set to false on changeSets that include a call that could fail.

                <changeSet failOnError="false">
                   <createSequence sequenceName="new_sequence"/>
                </changeSet>
                

                这允许你有简单的创建用户、创建序列、删除用户和删除序列更改集,如果语句因为用户/序列存在/不存在而抛出错误,它们仍将被标记为运行和更新会继续.

                This allows you to have simple create user, create sequence, drop user, and drop sequence changeSets and if the statement throws an error because they users/sequences exist/don't exist they will still be marked as ran and the update will continue.

                这种方法的缺点是它也会将它们标记为已运行并在它们由于其他原因(错误权限、连接失败、无效 SQL 等)出错时继续.更准确的方法是使用前提条件,像这样:

                The downside of this approach is that it will also mark them as ran and continue if they error for some other reason (bad permissions, connection failure, invalid SQL, etc.) The more accurate approach is to use preconditions, like this:

                <changeSet>
                   <preconditions onFail="MARK_RAN"><not><sequenceExists/></not></preconditions>
                   <createSequence name="new_sequence"/>
                </changeSet>
                

                当前没有 userExists 前提条件,但您可以创建自定义前提条件或回退到前提条件.有关文档,请参阅http://www.liquibase.org/documentation/preconditions.html

                There is no userExists precondition currently, but you can create custom preconditions or fall back to the precondition. See http://www.liquibase.org/documentation/preconditions.html for documentation

                这篇关于在删除不存在的序列、创建现有用户时防止出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何在 PL/SQL 中按每天分组? 下一篇:IF NOT EXISTS 在函数 PLSQL 中

                相关文章

                1. <small id='wR3Hv'></small><noframes id='wR3Hv'>

                  <legend id='wR3Hv'><style id='wR3Hv'><dir id='wR3Hv'><q id='wR3Hv'></q></dir></style></legend>
                  <tfoot id='wR3Hv'></tfoot>
                  1. <i id='wR3Hv'><tr id='wR3Hv'><dt id='wR3Hv'><q id='wR3Hv'><span id='wR3Hv'><b id='wR3Hv'><form id='wR3Hv'><ins id='wR3Hv'></ins><ul id='wR3Hv'></ul><sub id='wR3Hv'></sub></form><legend id='wR3Hv'></legend><bdo id='wR3Hv'><pre id='wR3Hv'><center id='wR3Hv'></center></pre></bdo></b><th id='wR3Hv'></th></span></q></dt></tr></i><div id='wR3Hv'><tfoot id='wR3Hv'></tfoot><dl id='wR3Hv'><fieldset id='wR3Hv'></fieldset></dl></div>

                      <bdo id='wR3Hv'></bdo><ul id='wR3Hv'></ul>