この例では、emp
表に、empno
列に基づく2つのパーティションがあります。emp
表をdeptno
列で再パーティション化します。
別の列で表を再パーティション化するには、次の手順を実行してください。
次に、これらの手順の例を示します。
> exp scott table=emp file=empexp.dat . . . About to export specified tables via Conventional Path ... . . exporting table EMP . . exporting partition EMP_LOW 4 rows exported . . exporting partition EMP_HIGH 10 rows exported Export terminated successfully without warnings. SQL> connect scott Connected. SQL> drop table emp cascade constraints; Statement processed. SQL> create table emp 2 ( 3 empno number(4) not null, 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 ) 12 partition by range (deptno) 13 ( 14 partition dept_low values less than (15) 15 tablespace tbs_1, 16 partition dept_mid values less than (25) 17 tablespace tbs_2, 18 partition dept_high values less than (35) 19 tablespace tbs_3 20 ); Statement processed. SQL> exit > imp scott tables=emp file=empexp.dat ignore=y . . . import done in WE8DEC character set and AL16UTF16 NCHAR character set . importing SCOTT's objects into SCOTT . . importing partition "EMP":"EMP_LOW" 4 rows imported . . importing partition "EMP":"EMP_HIGH" 10 rows imported Import terminated successfully without warnings.
次に示すSQLのSELECT
文では、データはdeptno
列でパーティション化されます。
SQL> connect scott Connected. SQL> select empno, deptno from emp partition (dept_low); EMPNO DEPTNO ---------- ---------- 7782 10 7839 10 7934 10 3 rows selected. SQL> select empno, deptno from emp partition (dept_mid); EMPNO DEPTNO ---------- ---------- 7369 20 7566 20 7788 20 7876 20 7902 20 5 rows selected. SQL> select empno, deptno from emp partition (dept_high); EMPNO DEPTNO ---------- ---------- 7499 30 7521 30 7654 30 7698 30 7844 30 7900 30 6 rows selected. SQL> exit;