函数索引构成虚拟隐藏列

2019-08-18 13:15:51 浏览数 (1)

《enq: TM - contention锁争用的解决》中提到了SYS_NC00004$,理解不是很明白,于是在OTN上发了帖子咨询了下,

从回复看,SYS_NC00004$就是原始列名,只是他是个虚拟隐藏的列,并且数据默认值是“原始列”,即函数表达式作用的列,

The "construction rule" is the original column. If you query dba_tab_cols you'll see that sys_nc00004$ is a virtual hidden column with its data_default being the original column.

检索user_tab_cols视图,

代码语言:javascript复制
SQL> select table_name, column_name, data_type, data_default, hidden_column, virtual_column,qualified_col_name from user_tab_cols where table_name='PRODUCT';
qualified_col_name from user_tab_cols where table_name='PRODUCT';

P.S. user_tab_cols和user_tab_columns相比,有些列未做过滤。

DBA_TAB_COLS describes the columns of all tables, views, and clusters in the database. This view differs from "DBA_TAB_COLUMNS" in that hidden columns are not filtered out. Its columns are the same as those in "ALL_TAB_COLS". To gather statistics for this view, use the DBMS_STATS package.

可以看出来,PRODUCT表确实除了正常的三个字段外,多了一个列名SYS_NC00004$的字段,数据类型是RAW的,只有他含默认值,带引号的"SUPPLIER_ID",应该就是对SUPPLIER_ID加了函数,HIDDEN_COLUMN和VIRTUAL_COLUMN都是YES,他是一个虚拟隐藏列,

只能赞叹Oracle的博大精深,各种小知识点,层出不穷,应接不暇。。。

0 人点赞