简体   繁体   English

Oracle 10g范围分区查询

[英]Oracle 10g Range Partition Query

How can I partition by range for: one for pubdate values less than Jan 1, 2000; 如何按范围划分:一个用于pubdate值小于2000年1月1日; one for pubdate values greater than or equal to Jan 1, 2000 and less than Jan 1, 2010; 一个用于pubdate值大于或等于2000年1月1日且小于2010年1月1日; and a third partition for all pubdate values greater than or equal to Jan 1, 2010. 以及所有pubdate值大于或等于2010年1月1日的第三个分区。

How can I write my query for the partition part? 如何为分区部分编写查询? I've tried to look up examples, but I just don't understand what to put after partition. 我试图查找示例,但我只是不明白分区后要放什么。

My query is here: 我的问题在这里:

CREATE table lab6_zl (
ID number not null, 
title varchar2(40), 
pubID char(3), 
pubdate date,
constraint lab6_pk primary key(ID))
Partition by range (pubdate)
(Partition one for pubdate values greater than or equal to Jan 1, 2000),
(Partition two for for pubdate values less than Jan 1, 2000),
(Partition three for all pubdate values greater than or equal to Jan 1, 2010);

Try this: 试试这个:

create table LAB6_ZL
(
  ID        number not null
 ,TITLE     varchar2(40)
 ,PUBID     char(3)
 ,PUBDATE   date
 ,constraint LAB6_PK primary key(ID)
)
partition by range (PUBDATE)
  (partition TWO
     values less than (date '2000-01-01')
  ,partition ONE
     values less than (date '2010-01-01')
  ,partition THREE
     values less than (MAXVALUE));

The order of the partitions must be ascending so partition TWO is created first as it is less than the year 2000 while ONE is therefore between 2000 and 2009. The keyword MAXVALUE basically means no upper value, or, anything on or after 1st January 2010. 分区的顺序必须是升序的,因此首先创建分区TWO因为它小于2000年,而ONE因此在2000年到2009年之间。关键字MAXVALUE基本上没有上限值,或者在2010年1月1日或之后的任何内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM