<tfoot id='aDS4C'></tfoot>

    <legend id='aDS4C'><style id='aDS4C'><dir id='aDS4C'><q id='aDS4C'></q></dir></style></legend>
  • <small id='aDS4C'></small><noframes id='aDS4C'>

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

        oracle 中的修改列 - 如何在设置为可为空之前检查列是否可为空?

        MODIFY COLUMN in oracle - How to check if a column is nullable before setting to nullable?(oracle 中的修改列 - 如何在设置为可为空之前检查列是否可为空?)

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

          • <bdo id='Viiz6'></bdo><ul id='Viiz6'></ul>
            <tfoot id='Viiz6'></tfoot>

            <legend id='Viiz6'><style id='Viiz6'><dir id='Viiz6'><q id='Viiz6'></q></dir></style></legend>
          • <i id='Viiz6'><tr id='Viiz6'><dt id='Viiz6'><q id='Viiz6'><span id='Viiz6'><b id='Viiz6'><form id='Viiz6'><ins id='Viiz6'></ins><ul id='Viiz6'></ul><sub id='Viiz6'></sub></form><legend id='Viiz6'></legend><bdo id='Viiz6'><pre id='Viiz6'><center id='Viiz6'></center></pre></bdo></b><th id='Viiz6'></th></span></q></dt></tr></i><div id='Viiz6'><tfoot id='Viiz6'></tfoot><dl id='Viiz6'><fieldset id='Viiz6'></fieldset></dl></div>
              <tbody id='Viiz6'></tbody>
                • 本文介绍了oracle 中的修改列 - 如何在设置为可为空之前检查列是否可为空?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我试图替一位同事做一些 Oracle 工作,但遇到了一个障碍.在尝试编写脚本以将列修改为可为空时,我遇到了可爱的 ORA-01451 错误:

                  I'm trying to fill in for a colleague in doing some Oracle work, and ran into a snag. In attempting to write a script to modify a column to nullable, I ran into the lovely ORA-01451 error:

                  ORA-01451: column to be modified to NULL cannot be modified to NULL
                  

                  发生这种情况是因为该列已经为 NULL.我们有几个需要更新的数据库,所以在我错误的假设中,我认为将它设置为 NULL 应该可以全面确保每个人都是最新的,无论他们是否手动将此列设置为可空.但是,这显然会导致某些已经将该列设为可为空的人出错.

                  This is happening because the column is already NULL. We have several databases that need to be udpated, so in my faulty assumption I figured setting it to NULL should work across the board to make sure everybody was up to date, regardless of whether they had manually set this column to nullable or not. However, this apparently causes an error for some folks who already have the column as nullable.

                  如何检查一列是否已经可以为空以避免错误?可以实现这个想法的东西:

                  How does one check if a column is already nullable so as to avoid the error? Something that would accomplish this idea:

                  IF( MyTable.MyColumn IS NOT NULLABLE)
                     ALTER TABLE MyTable MODIFY(MyColumn  NULL);
                  

                  推荐答案

                  您可以在 PL/SQL 中执行此操作:

                  You could do this in PL/SQL:

                  declare
                    l_nullable user_tab_columns.nullable%type;
                  begin
                    select nullable into l_nullable
                    from user_tab_columns
                    where table_name = 'MYTABLE'
                    and   column_name = 'MYCOLUMN';
                  
                    if l_nullable = 'N' then
                      execute immediate 'alter table mytable modify (mycolumn null)';
                    end if;
                  end;
                  

                  这篇关于oracle 中的修改列 - 如何在设置为可为空之前检查列是否可为空?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to redirect the output of DBMS_OUTPUT.PUT_LINE to a file?(如何将 DBMS_OUTPUT.PUT_LINE 的输出重定向到文件?)
                  How do I get column datatype in Oracle with PL-SQL with low privileges?(如何使用低权限的 PL-SQL 在 Oracle 中获取列数据类型?)
                  Get a list of all functions and procedures in an Oracle database(获取 Oracle 数据库中所有函数和过程的列表)
                  Why cannot I create triggers on objects owned by SYS?(为什么我不能在 SYS 拥有的对象上创建触发器?)
                  Returning result even for elements in IN list that don#39;t exist in table(即使对于表中不存在的 IN 列表中的元素也返回结果)
                  Reset Sequence in oracle 11g(oracle 11g 中的重置序列)
                • <i id='IgZs5'><tr id='IgZs5'><dt id='IgZs5'><q id='IgZs5'><span id='IgZs5'><b id='IgZs5'><form id='IgZs5'><ins id='IgZs5'></ins><ul id='IgZs5'></ul><sub id='IgZs5'></sub></form><legend id='IgZs5'></legend><bdo id='IgZs5'><pre id='IgZs5'><center id='IgZs5'></center></pre></bdo></b><th id='IgZs5'></th></span></q></dt></tr></i><div id='IgZs5'><tfoot id='IgZs5'></tfoot><dl id='IgZs5'><fieldset id='IgZs5'></fieldset></dl></div>

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

                        <legend id='IgZs5'><style id='IgZs5'><dir id='IgZs5'><q id='IgZs5'></q></dir></style></legend>
                          <tbody id='IgZs5'></tbody>

                          1. <tfoot id='IgZs5'></tfoot>

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