Oracle 11g新特性虚拟列分区

2022-08-27 17:16:12 浏览数 (1)

大家好,又见面了,我是全栈君。

如今有个需求:一个单据表要依照月份来分区。假设是在Oracle 10g上,仅仅能再加一个字段。

在Oracle 11g以后就不一样了。能够用虚拟列处理。

SQL> select * from v$version; BANNER ——————————————————————————– Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 – 64bit Production PL/SQL Release 11.2.0.1.0 – Production CORE 11.2.0.1.0 Production TNS for Linux: Version 11.2.0.1.0 – Production NLSRTL Version 11.2.0.1.0 – Production

SQL> create table t_virtual ( object_id number, object_name varchar2(100), created date ) partition by list(to_number(to_char(created, ‘MM’))) ( partition P1 VALUES (1), partition P2 VALUES (2), partition P3 VALUES (3), partition P4 VALUES (4), partition P5 VALUES (5), partition P6 VALUES (6), partition P7 VALUES (7), partition P8 VALUES (8), partition P9 VALUES (9), partition P10 VALUES (10), partition P11 VALUES (11), partition P12 VALUES (12) ); partition by list(to_number(to_char(created, ‘MM’))) * 第 7 行出现错误: ORA-00907: 缺失右括号

SQL> create table t_virtual ( object_id number, object_name varchar2(100), created date, create_year AS (to_number(to_char(created, ‘MM’))) ) partition by list(create_year) ( partition P1 VALUES (1), partition P2 VALUES (2), partition P3 VALUES (3), partition P4 VALUES (4), partition P5 VALUES (5), partition P6 VALUES (6), partition P7 VALUES (7), partition P8 VALUES (8), partition P9 VALUES (9), partition P10 VALUES (10), partition P11 VALUES (11), partition P12 VALUES (12) ); 表已创建。

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/115954.html原文链接:https://javaforall.cn

0 人点赞