Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2833839
  • 博文数量: 200
  • 博客积分: 2413
  • 博客等级: 大尉
  • 技术积分: 3067
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-01 22:07
文章分类

全部博文(200)

文章存档

2018年(2)

2017年(8)

2016年(35)

2015年(14)

2014年(20)

2013年(24)

2012年(53)

2011年(44)

分类: Oracle

2012-01-27 20:34:14

按照range列是date类型 创建分区表命令

  1. create table part_table(id number,stat_date date)
  2. partition by range (stat_date)
  3. (
  4. partition p1 values less than (to_date('2012-01-09','yyyy-mm-dd')),
  5. partition p2 values less than (to_date('2012-01-10','yyyy-mm-dd')),
  6. partition p3 values less than (to_date('2012-01-11','yyyy-mm-dd'))
  7. )
 
查询表分区信息,表名、分区名。
  1. select table_name,partition_name from user_tab_partitions where table_name='PART_TABLE' order by table_name,partition_name;

 

range列为非date类型创建分区表;

  1. create table part_table(id number,stat_date varchar2(100))

  2. partition by range (stat_date)

  3. (

  4. partition p1 values less than ('2012-01-09'),

  5. partition p2 values less than ('2012-01-10'),

  6. partition p3 values less than ('2012-01-11')

  7. )

 

插入数据,然后查询是否插入到争取的分区中

  1. insert into part_table values(1,'2012-01-08');
  2. select * from part_table partition(p1);
  3. ID STAT_DATE
  4. ---------------------- ------------------

  5. 1 2012-01-08


  6. insert into part_table values(1,'2012-01-09');
  7. select * from part_table partition(p2);
  8. ID STAT_DATE
  9. ---------------------- ----------------------

  10. 1 2012-01-09


  11. insert into part_table values(1,'2012-01-10');
  12. select * from part_table partition(p3);
  13. ID STAT_DATE
  14. ---------------------- ----------------------

  15. 1 2012-01-10
都正确插入,成功! 
阅读(7351) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~