现在有个需求:一个单据表要按照月份来分区,如果是在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)
);
表已创建。
在CentOS 6.4下安装Oracle 11gR2(x64)
Oracle 11gR2 在VMWare虚拟机中安装步骤
Debian 下 安装 Oracle 11g XE R2
Oracle性能优化 之 共享池
: