Indexing on Virtual Columns
发表于:2025-01-22 作者:千家信息网编辑
千家信息网最后更新 2025年01月22日,Virtual columns can be indexed like any other non virtual columns. The index created is always a fun
千家信息网最后更新 2025年01月22日Indexing on Virtual Columns
Virtual columns can be indexed like any other non virtual columns. The index created is always a function based index. If the index is B-tree index, it is recognized as FUNCTION-BASED NORMAL. For bitmap indexes, it is recognized as FUNCTION-BASED BITMAP.
SQL> col DATA_TYPE for a30
SQL> col DATA_DEFAULT for a30
SQL> SELECT column_name, data_type, data_length, data_default, virtual_column
2 FROM user_tab_cols
3 WHERE table_name = 'ORDERS_VCOL';
COLUMN_NAME DATA_TYPE DATA_LENGTH DATA_DEFAULT VIR
------------------------------ ------------------------------ ----------- ------------------------------ ---
ORDER_ID NUMBER 22 NO
ORDER_DATE TIMESTAMP(6) WITH LOCAL TIME ZONE 11 NO
ORDER_MODE VARCHAR2 8 NO
CUSTOMER_ID NUMBER 22 NO
ORDER_STATUS NUMBER 22 NO
ORDER_TOTAL NUMBER 22 NO
SALES_REP_ID NUMBER 22 NO
PROMOTION_ID NUMBER 22 NO
VCOL_GMT TIMESTAMP(6) 11 SYS_EXTRACT_UTC("ORDER_DATE") YES
9 rows selected.
SQL> create index index_vcol on orders_vcol(VCOL_GMT);
Index created.
SQL>
SQL> select index_name,index_type,funcidx_status from user_indexes where table_name='ORDERS_VCOL';
INDEX_NAME INDEX_TYPE FUNCIDX_
------------------------------ --------------------------- --------
ORDERS_VPK NORMAL
INDEX_VCOL FUNCTION-BASED NORMAL ENABLED
SQL> SQL>
SQL>
SQL> select * from user_ind_expressions where index_name='INDEX_VCOL';
INDEX_NAME TABLE_NAME COLUMN_EXPRESSION COLUMN_POSITION
------------------------------ ------------------------- -------------------------------------------------------------------------------- ---------------
INDEX_VCOL ORDERS_VCOL SYS_EXTRACT_UTC("ORDER_DATE") 1
SQL> drop index INDEX_VCOL;
Index dropped.
SQL>
SQL>
SQL> create bitmap index INDEX_VCOL on ORDERS_VCOL(VCOL_GMT);
create bitmap index INDEX_VCOL on ORDERS_VCOL(VCOL_GMT)
*
ERROR at line 1:
ORA-25122: Only LOCAL bitmap indexes are permitted on partitioned tables
SQL>
SQL> SELECT table_name, partition_name, high_value, num_rows
2 FROM user_tab_partitions
3 where table_name='ORDERS_VCOL'
4 ORDER BY table_name, partition_name;
TABLE_NAME PARTITION_NAME HIGH_VALUE NUM_ROWS
------------------------- -------------------- ---------------------------------------- ----------
ORDERS_VCOL Q1_2005 TIMESTAMP' 2005-04-01 00:00:00'
ORDERS_VCOL Q2_2005 TIMESTAMP' 2005-07-01 00:00:00'
ORDERS_VCOL Q3_2005 TIMESTAMP' 2005-10-01 00:00:00'
ORDERS_VCOL Q4_2005 TIMESTAMP' 2006-01-01 00:00:00'
SQL>
SQL>
SQL> drop table ORDERS_VCOL;
Table dropped.
SQL> CREATE TABLE orders_vcol
2 ( order_id NUMBER(12),
3 order_date TIMESTAMP WITH LOCAL TIME ZONE,
4 order_mode VARCHAR2(8),
5 customer_id NUMBER(6),
6 order_status NUMBER(2),
7 order_total NUMBER(8,2),
8 sales_rep_id NUMBER(6),
9 promotion_id NUMBER(6),
10 vcol_gmt TIMESTAMP AS (SYS_EXTRACT_UTC(order_date))
11 virtual,
12 CONSTRAINT orders_vpk PRIMARY KEY(order_id)
13 );
Table created.
SQL>
SQL> create bitmap index INDEX_VCOL on ORDERS_VCOL(VCOL_GMT);
Index created.
SQL> select index_name,index_type,funcidx_status from user_indexes where table_name='ORDERS_VCOL';
INDEX_NAME INDEX_TYPE FUNCIDX_
------------------------------ --------------------------- --------
ORDERS_VPK NORMAL
INDEX_VCOL FUNCTION-BASED BITMAP ENABLED
SQL> select * from user_ind_expressions where index_name='INDEX_VCOL';
INDEX_NAME TABLE_NAME COLUMN_EXPRESSION COLUMN_POSITION
------------------------------ ------------------------- -------------------------------------------------------------------------------- ---------------
INDEX_VCOL ORDERS_VCOL SYS_EXTRACT_UTC("ORDER_DATE") 1
Virtual columns can be indexed like any other non virtual columns. The index created is always a function based index. If the index is B-tree index, it is recognized as FUNCTION-BASED NORMAL. For bitmap indexes, it is recognized as FUNCTION-BASED BITMAP.
SQL> col DATA_TYPE for a30
SQL> col DATA_DEFAULT for a30
SQL> SELECT column_name, data_type, data_length, data_default, virtual_column
2 FROM user_tab_cols
3 WHERE table_name = 'ORDERS_VCOL';
COLUMN_NAME DATA_TYPE DATA_LENGTH DATA_DEFAULT VIR
------------------------------ ------------------------------ ----------- ------------------------------ ---
ORDER_ID NUMBER 22 NO
ORDER_DATE TIMESTAMP(6) WITH LOCAL TIME ZONE 11 NO
ORDER_MODE VARCHAR2 8 NO
CUSTOMER_ID NUMBER 22 NO
ORDER_STATUS NUMBER 22 NO
ORDER_TOTAL NUMBER 22 NO
SALES_REP_ID NUMBER 22 NO
PROMOTION_ID NUMBER 22 NO
VCOL_GMT TIMESTAMP(6) 11 SYS_EXTRACT_UTC("ORDER_DATE") YES
9 rows selected.
SQL> create index index_vcol on orders_vcol(VCOL_GMT);
Index created.
SQL>
SQL> select index_name,index_type,funcidx_status from user_indexes where table_name='ORDERS_VCOL';
INDEX_NAME INDEX_TYPE FUNCIDX_
------------------------------ --------------------------- --------
ORDERS_VPK NORMAL
INDEX_VCOL FUNCTION-BASED NORMAL ENABLED
SQL> SQL>
SQL>
SQL> select * from user_ind_expressions where index_name='INDEX_VCOL';
INDEX_NAME TABLE_NAME COLUMN_EXPRESSION COLUMN_POSITION
------------------------------ ------------------------- -------------------------------------------------------------------------------- ---------------
INDEX_VCOL ORDERS_VCOL SYS_EXTRACT_UTC("ORDER_DATE") 1
SQL> drop index INDEX_VCOL;
Index dropped.
SQL>
SQL>
SQL> create bitmap index INDEX_VCOL on ORDERS_VCOL(VCOL_GMT);
create bitmap index INDEX_VCOL on ORDERS_VCOL(VCOL_GMT)
*
ERROR at line 1:
ORA-25122: Only LOCAL bitmap indexes are permitted on partitioned tables
SQL>
SQL> SELECT table_name, partition_name, high_value, num_rows
2 FROM user_tab_partitions
3 where table_name='ORDERS_VCOL'
4 ORDER BY table_name, partition_name;
TABLE_NAME PARTITION_NAME HIGH_VALUE NUM_ROWS
------------------------- -------------------- ---------------------------------------- ----------
ORDERS_VCOL Q1_2005 TIMESTAMP' 2005-04-01 00:00:00'
ORDERS_VCOL Q2_2005 TIMESTAMP' 2005-07-01 00:00:00'
ORDERS_VCOL Q3_2005 TIMESTAMP' 2005-10-01 00:00:00'
ORDERS_VCOL Q4_2005 TIMESTAMP' 2006-01-01 00:00:00'
SQL>
SQL>
SQL> drop table ORDERS_VCOL;
Table dropped.
SQL> CREATE TABLE orders_vcol
2 ( order_id NUMBER(12),
3 order_date TIMESTAMP WITH LOCAL TIME ZONE,
4 order_mode VARCHAR2(8),
5 customer_id NUMBER(6),
6 order_status NUMBER(2),
7 order_total NUMBER(8,2),
8 sales_rep_id NUMBER(6),
9 promotion_id NUMBER(6),
10 vcol_gmt TIMESTAMP AS (SYS_EXTRACT_UTC(order_date))
11 virtual,
12 CONSTRAINT orders_vpk PRIMARY KEY(order_id)
13 );
Table created.
SQL>
SQL> create bitmap index INDEX_VCOL on ORDERS_VCOL(VCOL_GMT);
Index created.
SQL> select index_name,index_type,funcidx_status from user_indexes where table_name='ORDERS_VCOL';
INDEX_NAME INDEX_TYPE FUNCIDX_
------------------------------ --------------------------- --------
ORDERS_VPK NORMAL
INDEX_VCOL FUNCTION-BASED BITMAP ENABLED
SQL> select * from user_ind_expressions where index_name='INDEX_VCOL';
INDEX_NAME TABLE_NAME COLUMN_EXPRESSION COLUMN_POSITION
------------------------------ ------------------------- -------------------------------------------------------------------------------- ---------------
INDEX_VCOL ORDERS_VCOL SYS_EXTRACT_UTC("ORDER_DATE") 1
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
浙江省网络安全总工程师蔡林
东台辉之悦网络技术服务中心
互联网科技与银行关系
什么是大平台数据库
福州 对日软件开发
4k显示器软件开发
数据库中平均分怎么设置
黑龙江智能软件开发
国家计算机数据库技术
南京crm软件开发哪家好
安全模式 注册服务器已停止
服务器添加IBM存储
华为 单板软件开发部
温州中广网络技术公司
连接数据库的驱动是干什么
海北州委网络安全局
黄可臻 网络安全
岩相古地理图数据库
中国中小企业创新创业数据库
欧盟数据库指令原文
ros web 服务器
小学生网络安全的心得体会
c怎么查询数据库
北京网警网络安全
黑客对于网络安全的危害
数据库 空间
博尔塔拉软件开发联系方式
综合软件开发定制服务费
服务器监控硬盘安装
警用网络安全