Oracle ORA-14148问题

来源:这里教程网 时间:2026-03-03 12:58:24 作者:

Oracle12.1的库里一张表上存在一个隐藏列,需要把它删掉。隐藏列可以通过sys.dba_tab_cols查看。 使用下面的命令 alter table A drop unused columns; alter table A drop column "SYS_NC00027$"; 以上语法都没有能把列删掉。第一条没有任何报错,第二条报错如下: ORA-14148: DML and DDL operations are not directly allowed on the guard-column. 这个隐藏列的产生,其实是因为Oracle12c的一个新特性。12c之前,在向表添加带有默认值的列的时候,如果不想影响生产,那么需要default+not null,这种方式只会去修改数据字典,速度很快,否则会实际的物理更新每一行,速度很慢,影响生产业务。12c以后,添加default值的列不加not null也很快,这背后的实现技术是通过向表添加隐藏列实现的。具体情况之前写过一篇博客: http://blog.itpub.net/31480688/viewspace-2153741/ 这个问题是一个未公布的bug,Bug 18506065。解决方法如下: 1.安装 Patch 18506065 2.升级到Bug 18506065被修复的12.2 3.临时workaround: alter system set "_add_col_optim_enabled"=false; 隐含参数含义: SQL>  select a.ksppinm name,b.ksppstvl value,a.ksppdesc description   2      from x$ksppi a,x$ksppcv b   3     where a.inst_id = USERENV ('Instance')   4       and b.inst_id = USERENV ('Instance')   5       and a.indx = b.indx   6       and upper(a.ksppinm) LIKE upper('%add_col_optim_enabled%')   7       order by name; NAME -------------------------------------------------------------------------------- VALUE -------------------------------------------------------------------------------- DESCRIPTION -------------------------------------------------------------------------------- _add_col_optim_enabled TRUE Allows new add column optimization 此外,数据泵导出加参数version=10.2,导入的时候也可能会报这个错,也可以先修改_add_col_optim_enabled为false,导完之后再修改回来。

相关推荐