How To Use Virtual Column-Based Partitioning
发表于:2024-12-13 作者:千家信息网编辑
千家信息网最后更新 2024年12月13日,上一篇我介绍和测试了oracle 11g版本引入的虚拟列新特性,本文继续测试分区键基于表的虚拟列:Prior releases of Oracle only allowed a table to be
千家信息网最后更新 2024年12月13日How To Use Virtual Column-Based Partitioning上一篇我介绍和测试了oracle 11g版本引入的虚拟列新特性,本文继续测试分区键基于表的虚拟列:
Prior releases of Oracle only allowed a table to be partitioned based on a physical column. Oracle 11g, with the addition of virtual columns, now allows a partition key based on an expression, using one or more existing columns of the table. A virtual column can now be used as a partitioning key.Oracle 11g supports the concept of virtual columns on tables. These virtual columns are not physically stored in the table, but derived from data in the table. These virtual columns can be used in the partition key in all basic partitioning schemes. The example below creates a table that is list partitioned on a virtual column that represents the first letter in the username column of the table.
SQL> CREATE TABLE orders --------------------scripts from oracle 11g doc(Example 4-9 Creating reference-partitioned tables)
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 CONSTRAINT orders_pk PRIMARY KEY(order_id)
11 )
12 PARTITION BY RANGE(order_date)
13 ( PARTITION Q1_2005 VALUES LESS THAN (TO_DATE('01-APR-2005','DD-MON-YYYY')),
14 PARTITION Q2_2005 VALUES LESS THAN (TO_DATE('01-JUL-2005','DD-MON-YYYY')),
15 PARTITION Q3_2005 VALUES LESS THAN (TO_DATE('01-OCT-2005','DD-MON-YYYY')),
16 PARTITION Q4_2005 VALUES LESS THAN (TO_DATE('01-JAN-2006','DD-MON-YYYY'))
17 );
( PARTITION Q1_2005 VALUES LESS THAN (TO_DATE('01-APR-2005','DD-MON-YYYY')),
*
ERROR at line 13:
ORA-30078: partition bound must be TIME/TIMESTAMP WITH TIME ZONE literals
SQL> CREATE TABLE orders_vcol
2 ( order_id NUMBER(12),
3 order_date TIMESTAMP(6) 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(6) AS (SYS_EXTRACT_UTC(order_date))
11 virtual,
12 CONSTRAINT orders_vpk PRIMARY KEY(order_id)
13 )
14 PARTITION BY RANGE(vcol_gmt)
15 ( PARTITION Q1_2005 VALUES LESS THAN (TO_DATE('01-APR-2005','DD-MON-YYYY')),
16 PARTITION Q2_2005 VALUES LESS THAN (TO_DATE('01-JUL-2005','DD-MON-YYYY')),
17 PARTITION Q3_2005 VALUES LESS THAN (TO_DATE('01-OCT-2005','DD-MON-YYYY')),
18 PARTITION Q4_2005 VALUES LESS THAN (TO_DATE('01-JAN-2006','DD-MON-YYYY'))
19 );
Table created.
SQL> COLUMN table_name FORMAT A25
SQL> COLUMN partition_name FORMAT A20
SQL> COLUMN high_value FORMAT A40
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'
Prior releases of Oracle only allowed a table to be partitioned based on a physical column. Oracle 11g, with the addition of virtual columns, now allows a partition key based on an expression, using one or more existing columns of the table. A virtual column can now be used as a partitioning key.Oracle 11g supports the concept of virtual columns on tables. These virtual columns are not physically stored in the table, but derived from data in the table. These virtual columns can be used in the partition key in all basic partitioning schemes. The example below creates a table that is list partitioned on a virtual column that represents the first letter in the username column of the table.
SQL> CREATE TABLE orders --------------------scripts from oracle 11g doc(Example 4-9 Creating reference-partitioned tables)
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 CONSTRAINT orders_pk PRIMARY KEY(order_id)
11 )
12 PARTITION BY RANGE(order_date)
13 ( PARTITION Q1_2005 VALUES LESS THAN (TO_DATE('01-APR-2005','DD-MON-YYYY')),
14 PARTITION Q2_2005 VALUES LESS THAN (TO_DATE('01-JUL-2005','DD-MON-YYYY')),
15 PARTITION Q3_2005 VALUES LESS THAN (TO_DATE('01-OCT-2005','DD-MON-YYYY')),
16 PARTITION Q4_2005 VALUES LESS THAN (TO_DATE('01-JAN-2006','DD-MON-YYYY'))
17 );
( PARTITION Q1_2005 VALUES LESS THAN (TO_DATE('01-APR-2005','DD-MON-YYYY')),
*
ERROR at line 13:
ORA-30078: partition bound must be TIME/TIMESTAMP WITH TIME ZONE literals
SQL> CREATE TABLE orders_vcol
2 ( order_id NUMBER(12),
3 order_date TIMESTAMP(6) 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(6) AS (SYS_EXTRACT_UTC(order_date))
11 virtual,
12 CONSTRAINT orders_vpk PRIMARY KEY(order_id)
13 )
14 PARTITION BY RANGE(vcol_gmt)
15 ( PARTITION Q1_2005 VALUES LESS THAN (TO_DATE('01-APR-2005','DD-MON-YYYY')),
16 PARTITION Q2_2005 VALUES LESS THAN (TO_DATE('01-JUL-2005','DD-MON-YYYY')),
17 PARTITION Q3_2005 VALUES LESS THAN (TO_DATE('01-OCT-2005','DD-MON-YYYY')),
18 PARTITION Q4_2005 VALUES LESS THAN (TO_DATE('01-JAN-2006','DD-MON-YYYY'))
19 );
Table created.
SQL> COLUMN table_name FORMAT A25
SQL> COLUMN partition_name FORMAT A20
SQL> COLUMN high_value FORMAT A40
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'
测试
版本
特性
上一
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
怎么共享电脑游戏服务器
大同公安局网络安全保卫支队
常见的数据库管理系统有哪些
春节期间网络安全工作布置会
腾讯云轻量应用服务器建站教程
天津房网网络技术有限公司
清水河租房软件开发
武汉大学网络安全研究生复试线
沃和赛腾网络技术
互联网时代软件开发特点
河西区信息网络技术诚信合作
网络安全建言献策范文大全
厦门畅游网络技术有限公司
捷达服务器
2003服务器管理器找不到
黑龙江攒云树网络技术有限公司
芜湖咖啡点餐软件开发要多少钱
虎牙宇宙服务器mod大全
dubbo部署服务器
评价对软件开发的质量
易道网络技术
人疲劳度测定数据库
甲骨文服务器地址区域
花都服务器运维服务公司
vba 保存网页数据库
ebi 数据库
高职网络技术专业教材
数据库到excel表格
手机网络安全问题发言300字
计算机网络安全事件引言