sql - Oracle 10g 范围分区查询

标签 sql oracle oracle10g partitioning

我如何按范围分区:一个用于小于 2000 年 1 月 1 日的 pubdate 值;一个用于大于或等于 2000 年 1 月 1 日且小于 2010 年 1 月 1 日的 pubdate 值;以及所有 pubdate 值大于或等于 2010 年 1 月 1 日的第三个分区。

如何编写对分区部分的查询?我试图查找示例,但我只是不明白分区后该放什么。

我的查询在这里:

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);

最佳答案

尝试这个:

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));

分区的顺序必须是升序所以分区 TWO首先创建,因为它小于 2000 年,而 ONE因此是在 2000 年到 2009 年之间。关键字 MAXVALUE基本上意味着没有上限值,或者 2010 年 1 月 1 日或之后的任何值。

关于sql - Oracle 10g 范围分区查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9419832/

相关文章:

c# - SQL Server返回给C#的是什么

oracle - oracle中select中的序列和大小写

oracle - 使用特定表名的Oracle View 列表

python - Jython,动态查询多列

sql - 编写查询以终止用户 session

MySql 内连接顺序

javascript - Html5 表示值未定义

sql - 如何在 SQL Server 中反转字符串

sql - 加入/哪里概念

oracle - 迁移 6i 到 10g Oracle 报告