码迷,mamicode.com
首页 > 数据库 > 详细

oracle分区表之列表分区

时间:2018-05-12 18:30:41      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:添加   ber   end   SQ   procedure   列表   created   weight   analyst   

SQL> -- Create test table
SQL> drop table list_partition_test;
Table dropped
SQL> create table list_partition_test
  2  (
  3    empno    NUMBER(4),
  4    ename    VARCHAR2(10),
  5    job      VARCHAR2(9),
  6    mgr      NUMBER(4),
  7    hiredate DATE,
  8    sal      NUMBER(7,2),
  9    comm     NUMBER(7,2),
 10    deptno   NUMBER(2),
 11    dt       VARCHAR2(20)
 12  )
 13  partition by list (DT)
 14  (
 15    partition DT_PARTITION values (20180512, 20180513, 20180514, 20180515)
 16  );
Table created
SQL> --添加数据
SQL> begin
  2    for i in 20180512..20180515 loop
  3    insert into list_partition_test select t.*,i from scott.emp t;
  4    end loop;
  5  end;
  6  /
PL/SQL procedure successfully completed
SQL> --用分区字段筛选查询
SQL> select *
  2    from list_partition_test
  3   where dt = 20180515;
EMPNO ENAME      JOB         MGR HIREDATE          SAL      COMM DEPTNO DT
----- ---------- --------- ----- ----------- --------- --------- ------ --------------------
 7369 SMITH      CLERK      7902 1980/12/17     800.00               20 20180515
 7499 ALLEN      SALESMAN   7698 1981/2/20     1600.00    300.00     30 20180515
 7521 WARD       SALESMAN   7698 1981/2/22     1250.00    500.00     30 20180515
 7566 JONES      MANAGER    7839 1981/4/2      2975.00               20 20180515
 7654 MARTIN     SALESMAN   7698 1981/9/28     1250.00   1400.00     30 20180515
 7698 BLAKE      MANAGER    7839 1981/5/1      2850.00               30 20180515
 7782 CLARK      MANAGER    7839 1981/6/9      2450.00               10 20180515
 7788 SCOTT      ANALYST    7566 1987/4/19     3000.00               20 20180515
 7839 KING       PRESIDENT       1981/11/17    5000.00               10 20180515
 7844 TURNER     SALESMAN   7698 1981/9/8      1500.00      0.00     30 20180515
 7876 ADAMS      CLERK      7788 1987/5/23     1100.00               20 20180515
 7900 JAMES      CLERK      7698 1981/12/3      950.00               30 20180515
 7902 FORD       ANALYST    7566 1981/12/3     3000.00               20 20180515
 7934 MILLER     CLERK      7782 1982/1/23     1300.00               10 20180515
14 rows selected

 

oracle分区表之列表分区

标签:添加   ber   end   SQ   procedure   列表   created   weight   analyst   

原文地址:https://www.cnblogs.com/wangzihong/p/9029319.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!