๐Ÿ’ป Programming (356)

์ž ์˜ค๋Š˜์€ concat()๊ณผ listagg()์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

 

DB์—์„œ ์ •๋ณด๋ฅผ ์ถ”์ถœํ•  ๋•Œ ์—ฌ๋Ÿฌ์ค„(๋ฆฌ์ŠคํŠธ ํ˜•ํƒœ)๋กœ ๋‚˜์˜ค๋Š” ๊ฒƒ๋“ค์„ ํ•œ์ค„๋กœ ํ•ฉ์ณ์„œ ๋ฝ‘์•„๋‚ด๊ณ  ์‹ถ๊ฑฐ๋‚˜  

 

ํ•œ ์ค„์— ์—ฌ๋Ÿฌ ํ•„๋“œ๋“ค์ด ์žˆ์„๋•Œ ์ด ํ•„๋“œ๋“ค์„ ๋ชจ๋‘ ํ•ฉ์ณ์„œ ํ•œ์ค„์˜ ์ŠคํŠธ๋ง์œผ๋กœ ๋ฝ‘์•„๋‚ด๊ณ  ์‹ถ์„ ๋•Œ๊ฐ€ ์žˆ์„๊ฑฐ์—์š”.

 

์˜ˆ๋ฅผ๋“ค๋ฉด EMPํ…Œ์ด๋ธ”์— ํ•œ๋ช…์˜ employee๋งŒ ๋“ฑ๋ก์ด ๋˜์–ด์žˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•ฉ์‹œ๋‹ค.

์ด๋•Œ ์ด ์‚ฌ๋žŒ์˜ ์ •๋ณด๋ฅผ emp_nm ๊ณผ emp_id๋ฅผ ๋‚˜๋ˆ ์„œ emp๊ฐ์ฒด์˜ name๊ณผ idํ•„๋“œ์— ๋ฝ‘์•„์˜ฌ ์ˆ˜๋„ ์žˆ์ง€๋งŒ ๊ถ‚์ด ์ด๊ฑธ ํ•˜๋‚˜์˜ String์œผ๋กœ ๋ฝ‘์•„๋‚ด๊ณ  ์‹ถ์„๋•Œ๊ฐ€ ์žˆ์„ ์ˆ˜๋„ ์žˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•˜๊ณ  -_-ใ…‹

 

emp_nm | emp_id

---------------

์žฅ๊ตฐ์ด   |     3

 

์ด๋ ‡๊ฒŒ ๋ฐ์ดํ„ฐ๊ฐ€ ๋“ค์–ด์žˆ์„ ๋•Œ "3์žฅ๊ตฐ์ด" ๋ผ๋Š” ์ŠคํŠธ๋ง์„ ๋ฝ‘์•„์˜ค๋ ค๋ฉด concat์„ ์“ฐ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

 

select concat( emp_id, emp_nm) from emp; 

 

์ด์ œ ๋ฐ์ดํƒ€๊ฐ€ ํ•œ์ค„ ๋” ๋“ค์–ด์™€์„œ ๋‘๋ช…์˜ employee๊ฐ€ ์žˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•ฉ์‹œ๋‹ค.

 

emp_nm | emp_id

---------------

์žฅ๊ตฐ์ด   |     3

์ด์ญ์ด   |     5

 

๊ทธ๋ฆฌ๊ณ  ์ด ์ง์›๋“ค์˜ ์ด๋ฆ„์„ ์‰ผํ‘œ๋กœ ๊ตฌ๋ถ„ํ•ด์„œ ํ•˜๋‚˜์˜ ์ŠคํŠธ๋ง์œผ๋กœ ๋ฝ‘์•„๋‚ด๊ณ  ์‹ถ๋‹ค๊ณ  ๊ฐ€์ •ํ•ฉ์‹œ๋‹ค.


"์žฅ๊ตฐ์ด,์ด์ญ์ด" ์ด๋ ‡๊ฒŒ ๋ง์ด์ฃ .

 

์ด๋Ÿด๋•Œ๋Š” listagg()๋ฅผ ์“ฐ๋ฉด ๋ฉ๋‹ˆ๋‹ค. ์•„๋ž˜์ฒ˜๋Ÿผ ๋ง์ด์ฃ .

 

select listagg(emp_nm, ',') within group ( order by emp_id ) from emp; 

 

listagg(๋ฆฌ์ŠคํŠธ์• ๊ทธ)์— ๋Œ€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ ์•„๋ž˜ ์ถœ์ฒ˜์— ์žˆ๋Š” ์ฃผ์†Œ๋กœ ๊ฐ€์‹œ๋ฉด ์ข€ ๋” ์ž์„ธํ•œ ์„ค๋ช…์„ ๋ณด์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

๊ทธ๋Ÿผ ์ข‹์€ํ•˜๋ฃจ ๋˜์„ธ์š”~ ^_^ 

 

 

 

 

์ถœ์ฒ˜ : http://oracle-base.com/articles/misc/string-aggregation-techniques.php ( listagg() )  

 

๋งํฌ๊ฐ€ break๋  ๊ฒƒ์„ ์šฐ๋ คํ•˜์—ฌ ๋ฐ‘์— ์œ„ ๋งํฌ๋กœ๊ฐ€๋ฉด ๋ณผ ์ˆ˜ ์žˆ๋Š” ๋‚ด์šฉ์„ ๊ฐ€์ ธ์™”์Šต๋‹ˆ๋‹ค. ^^

--------------------------------------------------------------------------------

String Aggregation Techniques

On occasion it is necessary to aggregate data from a number of rows into a single row, giving a list of data associated with a specific value. Using the SCOTT.EMP table as an example, we might want to retrieve a list of employees for each department. Below is a list of the base data and the type of output we would like to return from an aggregate query.

Base Data:

    DEPTNO ENAME
---------- ----------
        20 SMITH
        30 ALLEN
        30 WARD
        20 JONES
        30 MARTIN
        30 BLAKE
        10 CLARK
        20 SCOTT
        10 KING
        30 TURNER
        20 ADAMS
        30 JAMES
        20 FORD
        10 MILLER

Desired Output:

    DEPTNO EMPLOYEES
---------- --------------------------------------------------
        10 CLARK,KING,MILLER
        20 SMITH,FORD,ADAMS,SCOTT,JONES
        30 ALLEN,BLAKE,MARTIN,TURNER,JAMES,WARD

This article is based on a thread from asktom.oracle.com and contains several methods to achieve the desired results.

LISTAGG Analystic Function in 11g Release 2

The LISTAGG analytic function was introduced in Oracle 11g Release 2, making it very easy to aggregate strings. The nice thing about this function is it also allows us to order the elements in the concatenated list. If you are using 11g Release 2 you should use this function for string aggregation.

COLUMN employees FORMAT A50

SELECT deptno, LISTAGG(ename, ',') WITHIN GROUP (ORDER BY ename) AS employees
FROM   emp
GROUP BY deptno;

    DEPTNO EMPLOYEES
---------- --------------------------------------------------
        10 CLARK,KING,MILLER
        20 ADAMS,FORD,JONES,SCOTT,SMITH
        30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD

3 rows selected.

WM_CONCAT Built-in Function (Not Supported)

If you are not running 11g Release 2, but are running a version of the database where the WM_CONCAT function is present, then it is a zero effort solution as it performs the aggregation for you. It is actually an example of a user defined aggregate function described below, but Oracle have done all the work for you.

COLUMN employees FORMAT A50

SELECT deptno, wm_concat(ename) AS employees
FROM   emp
GROUP BY deptno;

    DEPTNO EMPLOYEES
---------- --------------------------------------------------
        10 CLARK,KING,MILLER
        20 SMITH,FORD,ADAMS,SCOTT,JONES
        30 ALLEN,BLAKE,MARTIN,TURNER,JAMES,WARD

3 rows selected.

Note. WM_CONCAT is an undocumented function and as such is not supported by Oracle for user applications (MOS Note ID 1336219.1). If this concerns you, use a User-Defined Aggregate Function described below.

User-Defined Aggregate Function

The WM_CONCAT function described above is an example of a user-defined aggregate function that Oracle have already created for you. If you don't want to use WM_CONCAT, you can create your own user-defined aggregate function as described at asktom.oracle.com.

CREATE OR REPLACE TYPE t_string_agg AS OBJECT
(
  g_string  VARCHAR2(32767),

  STATIC FUNCTION ODCIAggregateInitialize(sctx  IN OUT  t_string_agg)
    RETURN NUMBER,

  MEMBER FUNCTION ODCIAggregateIterate(self   IN OUT  t_string_agg,
                                       value  IN      VARCHAR2 )
     RETURN NUMBER,

  MEMBER FUNCTION ODCIAggregateTerminate(self         IN   t_string_agg,
                                         returnValue  OUT  VARCHAR2,
                                         flags        IN   NUMBER)
    RETURN NUMBER,

  MEMBER FUNCTION ODCIAggregateMerge(self  IN OUT  t_string_agg,
                                     ctx2  IN      t_string_agg)
    RETURN NUMBER
);
/
SHOW ERRORS


CREATE OR REPLACE TYPE BODY t_string_agg IS
  STATIC FUNCTION ODCIAggregateInitialize(sctx  IN OUT  t_string_agg)
    RETURN NUMBER IS
  BEGIN
    sctx := t_string_agg(NULL);
    RETURN ODCIConst.Success;
  END;

  MEMBER FUNCTION ODCIAggregateIterate(self   IN OUT  t_string_agg,
                                       value  IN      VARCHAR2 )
    RETURN NUMBER IS
  BEGIN
    SELF.g_string := self.g_string || ',' || value;
    RETURN ODCIConst.Success;
  END;

  MEMBER FUNCTION ODCIAggregateTerminate(self         IN   t_string_agg,
                                         returnValue  OUT  VARCHAR2,
                                         flags        IN   NUMBER)
    RETURN NUMBER IS
  BEGIN
    returnValue := RTRIM(LTRIM(SELF.g_string, ','), ',');
    RETURN ODCIConst.Success;
  END;

  MEMBER FUNCTION ODCIAggregateMerge(self  IN OUT  t_string_agg,
                                     ctx2  IN      t_string_agg)
    RETURN NUMBER IS
  BEGIN
    SELF.g_string := SELF.g_string || ',' || ctx2.g_string;
    RETURN ODCIConst.Success;
  END;
END;
/
SHOW ERRORS


CREATE OR REPLACE FUNCTION string_agg (p_input VARCHAR2)
RETURN VARCHAR2
PARALLEL_ENABLE AGGREGATE USING t_string_agg;
/
SHOW ERRORS

The aggregate function is implemented using a type and type body, and is used within a query.

COLUMN employees FORMAT A50

SELECT deptno, string_agg(ename) AS employees
FROM   emp
GROUP BY deptno;

    DEPTNO EMPLOYEES
---------- --------------------------------------------------
        10 CLARK,KING,MILLER
        20 SMITH,FORD,ADAMS,SCOTT,JONES
        30 ALLEN,BLAKE,MARTIN,TURNER,JAMES,WARD

3 rows selected.

Specific Function

One approach is to write a specific function to solve the problems. The get_employees function listed below returns a list of employees for the specified department.

CREATE OR REPLACE FUNCTION get_employees (p_deptno  in  emp.deptno%TYPE)
  RETURN VARCHAR2
IS
  l_text  VARCHAR2(32767) := NULL;
BEGIN
  FOR cur_rec IN (SELECT ename FROM emp WHERE deptno = p_deptno) LOOP
    l_text := l_text || ',' || cur_rec.ename;
  END LOOP;
  RETURN LTRIM(l_text, ',');
END;
/
SHOW ERRORS

The function can then be incorporated into a query as follows.

COLUMN employees FORMAT A50

SELECT deptno,
       get_employees(deptno) AS employees
FROM   emp
GROUP by deptno;

    DEPTNO EMPLOYEES
---------- --------------------------------------------------
        10 CLARK,KING,MILLER
        20 SMITH,JONES,SCOTT,ADAMS,FORD
        30 ALLEN,WARD,MARTIN,BLAKE,TURNER,JAMES

3 rows selected.

To reduce the number of calls to the function, and thereby improve performance, we might want to filter the rows in advance.

COLUMN employees FORMAT A50

SELECT e.deptno,
       get_employees(e.deptno) AS employees
FROM   (SELECT DISTINCT deptno
        FROM   emp) e;

    DEPTNO EMPLOYEES
---------- --------------------------------------------------
        10 CLARK,KING,MILLER
        20 SMITH,JONES,SCOTT,ADAMS,FORD
        30 ALLEN,WARD,MARTIN,BLAKE,TURNER,JAMES
        
3 rows selected.

Generic Function using Ref Cursor

An alternative approach is to write a function to concatenate values passed using a ref cursor. This is essentially the same as the previous example, except that the cursor is passed in making it generic, as shown below.

CREATE OR REPLACE FUNCTION concatenate_list (p_cursor IN  SYS_REFCURSOR)
  RETURN  VARCHAR2
IS
  l_return  VARCHAR2(32767); 
  l_temp    VARCHAR2(32767);
BEGIN
  LOOP
    FETCH p_cursor
    INTO  l_temp;
    EXIT WHEN p_cursor%NOTFOUND;
    l_return := l_return || ',' || l_temp;
  END LOOP;
  RETURN LTRIM(l_return, ',');
END;
/
SHOW ERRORS

The CURSOR function is used to allow a query to be passed to the function as a ref cursor, as shown below.

COLUMN employees FORMAT A50

SELECT e1.deptno,
       concatenate_list(CURSOR(SELECT e2.ename FROM emp e2 WHERE e2.deptno = e1.deptno)) employees
FROM   emp e1
GROUP BY e1.deptno;

    DEPTNO EMPLOYEES
---------- --------------------------------------------------
        10 CLARK,KING,MILLER
        20 SMITH,JONES,SCOTT,ADAMS,FORD
        30 ALLEN,WARD,MARTIN,BLAKE,TURNER,JAMES

3 rows selected.

Once again, the total number of function calls can be reduced by filtering the distinct values, rather than calling the function for each row.

COLUMN employees FORMAT A50

SELECT deptno,
       concatenate_list(CURSOR(SELECT e2.ename FROM emp e2 WHERE e2.deptno = e1.deptno)) employees
FROM   (SELECT DISTINCT deptno
        FROM emp) e1;

    DEPTNO EMPLOYEES
---------- --------------------------------------------------
        10 CLARK,KING,MILLER
        20 SMITH,JONES,SCOTT,ADAMS,FORD
        30 ALLEN,WARD,MARTIN,BLAKE,TURNER,JAMES

3 rows selected.

ROW_NUMBER() and SYS_CONNECT_BY_PATH functions in Oracle 9i

An example on williamrobertson.net uses the ROW_NUMBER() and SYS_CONNECT_BY_PATH functions to achieve the same result without the use of PL/SQL or additional type definitions.

SELECT deptno,
       LTRIM(MAX(SYS_CONNECT_BY_PATH(ename,','))
       KEEP (DENSE_RANK LAST ORDER BY curr),',') AS employees
FROM   (SELECT deptno,
               ename,
               ROW_NUMBER() OVER (PARTITION BY deptno ORDER BY ename) AS curr,
               ROW_NUMBER() OVER (PARTITION BY deptno ORDER BY ename) -1 AS prev
        FROM   emp)
GROUP BY deptno
CONNECT BY prev = PRIOR curr AND deptno = PRIOR deptno
START WITH curr = 1;

    DEPTNO EMPLOYEES
---------- --------------------------------------------------
        10 CLARK,KING,MILLER
        20 ADAMS,FORD,JONES,SCOTT,SMITH
        30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD

3 rows selected.

COLLECT function in Oracle 10g

An example on oracle-developer.net uses the COLLECT function in Oracle 10g to get the same result. This method requires a table type and a function to convert the contents of the table type to a string. I've altered his method slightly to bring it in line with this article.

CREATE OR REPLACE TYPE t_varchar2_tab AS TABLE OF VARCHAR2(4000);
/

CREATE OR REPLACE FUNCTION tab_to_string (p_varchar2_tab  IN  t_varchar2_tab,
                                          p_delimiter     IN  VARCHAR2 DEFAULT ',') RETURN VARCHAR2 IS
  l_string     VARCHAR2(32767);
BEGIN
  FOR i IN p_varchar2_tab.FIRST .. p_varchar2_tab.LAST LOOP
    IF i != p_varchar2_tab.FIRST THEN
      l_string := l_string || p_delimiter;
    END IF;
    l_string := l_string || p_varchar2_tab(i);
  END LOOP;
  RETURN l_string;
END tab_to_string;
/

The query below shows the COLLECT function in action.

COLUMN employees FORMAT A50

SELECT deptno,
       tab_to_string(CAST(COLLECT(ename) AS t_varchar2_tab)) AS employees
FROM   emp
GROUP BY deptno;
       
    DEPTNO EMPLOYEES
---------- --------------------------------------------------
        10 CLARK,KING,MILLER
        20 SMITH,JONES,SCOTT,ADAMS,FORD
        30 ALLEN,WARD,MARTIN,BLAKE,TURNER,JAMES
        
3 rows selected.




์ด์ƒ์ž…๋‹ˆ๋‹ค!!!


์•„...์Šฌํ”„๋„๋‹ค....์ด ์—๋Ÿฌ์˜ ์›์ธ์„ ์ฐพ๋Š๋ผ ์–ผ๋งˆ๋‚˜ ํ—ค๋งธ๋˜์ง€...

์ฟผ๋ฆฌ๋ฌธ์˜ ์ธ์ž๋กœ ๋“ค์–ด๊ฐ€๋Š” ๋…€์„๋“ค์ด 13๊ฐœ์ด๊ณ  ์ด ์ฟผ๋ฆฌ๋ฌธ์„ ์ŠคํŠธ๋ง + ์ŠคํŠธ๋ง ํ˜•์‹์œผ๋กœ ๋ฌถ์–ด๋†จ๋Š”๋ฐ ์ฝค๋งˆ๊ฐ€ ๋น ์ง„ ์ด์œ ๋กœ ๋ณ€์ˆ˜๋ช…์ด ๋ถ€์ ํ•ฉํ•˜๋‹ค๋Š” ์˜ค๋ฅ˜๋ฅผ ์ฐ์–ด๋Œ€๋‹ˆ ์ด๊ฑฐ ์›์ธ์„ ์–ด๋–ป๊ฒŒ ์ฐพ์œผ๋ผ๊ณ .!!!!!!

 

๊ตฌ๊ธ€๋ง ํ•ด๋ณด๋‹ˆ......

 

์ฝค๋งˆ๊ฐ€ ๋น ์ ธ๋„ ์ €๋Ÿฐ ์˜ค๋ฅ˜๋ฅผ ๋ฟŒ๋ฆฐ๋‹ค๋Š” ๊ฒƒ...

 

์ž˜ ๋ณด๋‹ˆ ์ธ์ž๊ฐ€ ๋งŽ์•„์„œ ์ค„๋ฐ”๊ฟˆํ•  ๋•Œ ์‰ผํ‘œ๋ฅผ ํ•˜๋‚˜ ๋นผ๋จน์—ˆ๋˜ ๊ฒƒ.


ํŠน์ • ํ…Œ์ด๋ธ”์˜ ์†์„ฑ์„ ์กฐํšŒํ•  ๋•Œ์—๋Š” ์•„๋ž˜ ๋‘๊ฐ€์ง€ ํ…Œ์ด๋ธ”์„ ๋ณด๋ฉด๋ฉ๋‹ˆ๋‹ค.

1. dba๊ถŒํ•œ์œผ๋กœ ๋ชจ๋“  ํ…Œ์ด๋ธ”์„ ์กฐํšŒํ•  ๊ฒฝ์šฐ : dba_tables

2. ์ผ๋ฐ˜ ์‚ฌ์šฉ์ž ๊ถŒํ•œ์œผ๋กœ ๋‚ด ์†Œ์œ ์˜ ํ…Œ์ด๋ธ”์„ ์กฐํšŒํ•  ๊ฒฝ์šฐ : user_tables

 

์•„๋ž˜ ์˜ˆ์ œ๋ฅผ ๋ณด๋ฉด

 

SQL > select * from user_tables;

 

๋ฅผ ์‹คํ–‰ํ•˜๋ฉด ๊ฝค๋‚˜ ๊ธด ํŽ˜์ด์ง€๋ฅผ ๋ณด๊ฒŒ ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค.  

putty๋ฅผ ์ด์šฉํ•ด์„œ DB์— ์ ‘์†ํ•œ ๋’ค pagesize์™€ linesize๋ฅผ ์„ค์ •ํ•˜์ง€ ์•Š์•˜์„ ๊ฒฝ์šฐ ํŠนํžˆ ๋” ๊ธธ๊ฒŒ ๋‚˜์˜ฌ๊ฑฐ์—์š”. 

๋งŒ์•ฝ pagesize์™€ linesize๋ฅผ ์„ค์ •ํ•˜์ง€ ์•Š์•˜๋‹ค๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ์‹คํ–‰ํ•ด๋ณด์„ธ์š”.

 

SQL > set pagesize 100

SQL > set linesize 3000

 

์œ„ ๋‘ ์ค„์„์˜ ๋‚ด์šฉ์€ ํ•œ ํŽ˜์ด์ง€์— 100 ๋ผ์ธ์ด ๋“ค์–ด๊ฐ€๊ณ  ํ•œ ๋ผ์ธ์— 3์ฒœ๊ฐœ์˜ ๋ฌธ์ž๊ฐ€ ๋“ค์–ด๊ฐ„๋‹ค๊ณ  ์ •์˜ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

 

๊ทธ๋ฆฌ๊ณ  ๋‹ค์‹œ select๋ฌธ์„ ์‹คํ–‰์‹œ์ผœ๋ณด๋ฉด ๊ทธ๋‚˜๋งˆ ๋ณด๊ธฐ์ข‹๊ฒŒ ๋‚˜์˜ฌ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๊ทธ๋ž˜๋„ ์•„์ง ์˜ ๋ง˜์— ์•ˆ๋“ค์ฃ ? 

์œ„ select๋ฌธ์„ ์‹คํ–‰์‹œํ‚ค๋ฉด ํ…Œ์ด๋ธ”๋ช…๊ณผ ํ•ด๋‹น ํ…Œ์ด๋ธ”์ด ์†ํ•ด์žˆ๋Š” ํ…Œ์ด๋ธ” ์ŠคํŽ˜์ด์Šค๋ช…์„ ์‹œ์ž‘์œผ๋กœ ์˜จ๊ฐ– ์†์„ฑ๋“ค์˜ ๊ฐ’์ด ๋‚˜์˜ฌ๊ฒƒ์ž…๋‹ˆ๋‹ค.  

์•„๋ž˜๋Š” user_tables์— ์–ด๋–ค ์ปฌ๋Ÿผ๋“ค์ด ์žˆ๋Š”์ง€๋ฅผ ๋ฝ‘์•„๋ณธ ๊ฒƒ์ธ๋ฐ ์•„๋ž˜ ์ปฌ๋Ÿผ์ค‘์—์„œ ์›ํ•˜๋Š” ๊ฒƒ๋งŒ ๋ฝ‘์•„์„œ ์กฐํšŒ๋ฅผ ํ•˜๋Š”๊ฒƒ์ด ๋ณด์ด์— ํ›จ์”ฌ ์ข‹์„ํ…Œ๋‹ˆ ๋ช‡๊ฐœ๋งŒ ๊ณจ๋ผ์„œ ์กฐํšŒํ•ด๋ณด์„ธ์š”. 

 

TABLE_NAME                      

TABLESPACE_NAME                 

CLUSTER_NAME                                                                               IOT_NAME                                                                                    

STATUS      

PCT_FREE    

PCT_USED   

INI_TRANS   

MAX_TRANS  

INITIAL_EXTENT  

NEXT_EXTENT  

MIN_EXTENTS  

MAX_EXTENTS  

PCT_INCREASE   

FREELISTS  

FREELIST_GROUPS  

LOG  

B    

NUM_ROWS      

BLOCKS  

EMPTY_BLOCKS   

AVG_SPACE   

CHAIN_CNT  

AVG_ROW_LEN A

VG_SPACE_FREELIST_BLOCKS  

NUM_FREELISTOW_MOVE  

GLO  

USE  

DURATION                                             

SKIP_COR MON CLUSTER_OWNER                                                                               

DEPENDEN  

COMPRESS  

COMPRESS_FOR  

DRO  

REA  

SEG  

RESULT_

์•„๋ž˜ ์ฟผ๋ฆฌ๋ฌธ์€ dba ์œ ์ €๋กœ ๋ชจ๋“  ํ…Œ์ด๋ธ” ์ŠคํŽ˜์ด์Šค์˜ ์‚ฌ์šฉ๋Ÿ‰( ์ด์šฉ๋Ÿ‰, ์‚ฌ์šฉ๋Ÿ‰, ๋‚จ์€์šฉ๋Ÿ‰ )์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ์–ป์–ด์˜จ๋‹ค.

 

select     a.TABLESPACE_NAME,
     a.BYTES MB_total,
     b.BYTES MB_free,
     b.largest,
     a.BYTES-b.BYTES MB_used,
     round(((a.BYTES-b.BYTES)/a.BYTES)*100,2) percent_used
from
     (
          select      TABLESPACE_NAME,
               sum(BYTES)/1048576 BYTES
          from      dba_data_files
          group      by TABLESPACE_NAME
     )
     a,
     (
          select      TABLESPACE_NAME,
               sum(BYTES)/1048576 BYTES ,
               max(BYTES)/1048576 largest
          from      dba_free_space
          group      by TABLESPACE_NAME
     )
     b
where      a.TABLESPACE_NAME=b.TABLESPACE_NAME
order      by ((a.BYTES-b.BYTES)/a.BYTES) desc;


์ธ๋ฑ์Šค์˜ ํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค๋ฅผ ๋ณ€๊ฒฝํ•˜๊ธฐ์œ„ํ•ด์„œ ์•„๋ž˜์™€ ๊ฐ™์€ ์ฟผ๋ฆฌ๋ฅผ ๋‚ ๋ ธ๋”๋‹ˆ ์ œ๋ชฉ์— ์“ฐ์ธ ์˜ค๋ฅ˜๊ฐ€ ๋‚ฌ๋‹ค.

 

SQL> alter index ์ธ๋ฑ์Šค๋ช… rebuild tablespace ํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค๋ช…;

 

์ด์œ ์ธ์ฆ‰์Šจ ์ธ๋ฑ์Šค๊ฐ€ ํŒŒํ‹ฐ์…”๋‹์ด ๋˜์–ด๋ฒ„๋ ค์„œ ํ•œ๋ฒˆ์— rebuildํ•  ์ˆ˜ ์—†๋‹ค๋Š” ์–˜๊ธฐ

ํ•ด๋‹น ์ธ๋ฑ์Šค๊ฐ€ ํŒŒํ‹ฐ์…”๋‹์ด ๋˜์–ด์žˆ๋Š”์ง€๋Š” ์•„๋ž˜์™€ ๊ฐ™์€ ๋ช…๋ น์–ด๋กœ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

 

SQL> select index_name,partitioned from dba_indexes where partitioned='YES' and table_name='ํ…Œ์ด๋ธ”๋ช…';

 

์ž ๊ทธ๋Ÿผ ์–ด๋–ป๊ฒŒ ํ•ด์•ผํ• ๊นŒ?? ์ธ๋ฑ์Šค๊ฐ€ ํŒŒํ‹ฐ์…”๋‹์ด ๋˜์—ˆ๋‹ค๋Š” ์–˜๊ธฐ๋Š” ํ…Œ์ด๋ธ”์ด ํŒŒํ‹ฐ์…”๋‹์ด ๋˜์–ด์žˆ๋‹ค๋Š” ์–˜๊ธฐ๊ฐ™์€๋ฐ....๊ทธ๋Ÿผ ์ด์ œ ์ด ์ธ๋ฑ์Šค๊ฐ€ ์–ด๋Š ํŒŒํ‹ฐ์…˜์—์„œ ์‚ฌ์šฉ์ด ๋˜๋Š”์ง€ ํ™•์ธํ•ด์„œ ๊ฐ ํŒŒํ‹ฐ์…˜๋ณ„๋กœ ์ธ๋ฑ์Šค๋ฅผ rebuildํ•˜๋ฉด ๋ ๊ฒƒ ๊ฐ™์€๋ฐ??

 

์šฐ์„  ์ด ์ธ๋ฑ์Šค๊ฐ€ ์–ด๋Š ํŒŒํ‹ฐ์…˜์—์„œ ์‚ฌ์šฉ๋˜๋Š”์ง€ ํ™•์ธํ•ด๋ณด์ž.

SQL> select index_name, partition_name from dba_ind_partitions where index_name='์ธ๋ฑ์Šค๋ช…';

 

INDEX_NAME                     PARTITION_NAME
------------------------------ ------------------------------
EE                             ARCH_STATE
EE                             CURR_STATE
EE                             PREV_STATE

๊ทธ๋ฆฌ๊ณ  ๊ฐ ํŒŒํ‹ฐ์…˜์— ๋Œ€ํ•ด์„œ ์ธ๋ฑ์Šค๋ฅผ rebuildํ•˜์ž.

SQL>  alter index ee rebuild partition  ARCH_STATE;
Index altered.

SQL>  alter index ee rebuild partition  CURR_STATE;
Index altered.

SQL>  alter index ee rebuild partition  PREV_STATE;
Index altered.

๊ฒŒ์ž„ ์˜ค๋ฐ”~!! 

alter index ee rebuild partition  ARCH_STATE;


์ด ์—๋Ÿฌ๊ฐ€ ๋‚ฌ์„ ๋•Œ ๋ญ ๋•Œ๋ฌธ์— busy๋ผ๊ณ  ๋‚˜์˜ค๋Š”์ง€ ๊ถ๊ธˆํ•˜๋‹ค๋ฉด??

sysdba๊ถŒํ•œ์œผ๋กœ ์•„๋ž˜ ์ฟผ๋ฆฌ๋ฅผ ๋‚ ๋ ค๋ณด์ž. ๋ฌด์Šจ์ฟผ๋ฆฌ ๋•Œ๋ฌธ์— ์–ด๋Š ํ…Œ์ด๋ธ”์ด lock์ด ๊ฑธ๋ ค์žˆ๋Š”์ง€ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. 

SELECT O.OBJECT_NAME, S.SID, S.SERIAL#, P.SPID, S.PROGRAM,S.USERNAME,
S.MACHINE,S.PORT , S.LOGON_TIME,SQ.SQL_FULLTEXT 
FROM V$LOCKED_OBJECT L, DBA_OBJECTS O, V$SESSION S, 
V$PROCESS P, V$SQL SQ 
WHERE L.OBJECT_ID = O.OBJECT_ID 
AND L.SESSION_ID = S.SID AND S.PADDR = P.ADDR 
AND S.SQL_ADDRESS = SQ.ADDRESS;


์œ„ ์ฟผ๋ฆฌ๋ฅผ ์‹คํ–‰ํ•ด์„œ SID์™€ SERIAL#์„ ์•Œ์•„๋‚ด๋ฉด ์•„๋ž˜์™€ ๊ฐ™์€ ๋ช…๋ น์œผ๋กœ ํ•ด๋‹น ์„ธ์…˜์„ ์ฃฝ์ผ ์ˆ˜ ์žˆ๋‹ค.

ALTER SYSTEM KILL SESSION 'SID, SERIAL#';

์ด์ƒ~!!! ๋‹น์‹ ์—๊ฒŒ ๋…ธ๋ ฅ๊ณผ ํ–‰์šด์˜ ์—ฌ์‹ ์ด ํ•จ๊ป˜ํ•˜์—ฌ ๋ฌธ์ œ๊ฐ€ ํ•ด๊ฒฐ๋˜๊ธฐ๋ฅผ~~


ํ…Œ์ด๋ธ” ์ŠคํŽ˜์ด์Šค๋ฅผ ํŠœ๋‹ํ•˜๋ ค๊ณ  ์•„๋ž˜ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•˜์˜€๋‹ค.

 

ALTER TABLESPACE ํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค๋ช… AUTOEXTEND ON NEXT 1024K;

 

๊ทธ๋žฌ๋”๋‹ˆ ์•„๋ž˜์ฒ˜๋Ÿผ ์˜ค๋ฅ˜๊ฐ€ ๋–จ์–ด์กŒ๋‹ค.

 

ORA-32773: operation not supported for smallfile tablespace ํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค๋ช…  

 

๊ตฌ๊ธ€๋งํ•ด์„œ ์–ป์–ด์˜จ ํ•ด๊ฒฐ์ฑ… ํ•˜๋‚˜. ์•„๋ž˜ ๊ฒฝ์šฐ๋ฅผ ์‚ดํŽด๋ณด๊ธฐ ๋ฐ”๋ž€๋‹ค.

 

 

SQL> alter tablespace users resize 300m;
alter tablespace users resize 300m
*
ERROR at line 1:
ORA-32773: operation not supported for smallfile tablespace USERS

SQL> select file_id, tablespace_name from dba_data_files;

   FILE_ID TABLESPACE_NAME
---------- ------------------------------
         1 SYSTEM
         2 UNDOTBS1
         3 SYSAUX
         4 USERS

SQL> alter database datafile 4 resize 300m;

Database altered.

//--------Description from online documents------------------------------------------------------------------
ORA-32773: operation not supported for smallfile tablespace string
Cause:
An attempt was made to perform. an operation which is supported only for bigfile tablespaces, e.g. resize tablespace.
Action: Use the appropriate clause of the ALTER DATABASE DATAFILE command instead.


SQL> alter tablespace users autoextend off;
alter tablespace users autoextend off
*
ERROR at line 1:
ORA-32773: operation not supported for smallfile tablespace USERS


SQL> alter database datafile 4 autoextend off;

Database altered.

 

์ถœ์ฒ˜ : http://blog.itpub.net/9765498/viewspace-259958/ 


ORA-00845: MEMORY_TARGET not supported on this system ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค!!!!!

์œผ์•…!!!!

 

์˜ค๋ผํด์„ ์žฌ์‹œ์ž‘ํ•˜๋ ค๊ณ  shutdown์‹œํ‚จ ๋’ค startup์„ ์‹คํ–‰์‹œ์ผฐ๋”๋‹ˆ ๊ฐ‘์ž๊ธฐ ์ด๋Ÿฐ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค.

๋ญฅ๋ฏธ?? ์ฒ˜์Œ ๋ณธ ์˜ค๋ฅ˜๋ผ ๋‹นํ™ฉใ… ใ… 

 

๊ตฌ๊ธ€๋งํ•ด๋ณด๋‹ˆ /dev/shm ๋งˆ์šดํŠธํ•œ๊ฑฐ๋ž‘ ๊ด€๋ จ์ด ์žˆ์—ˆ๋‹ค. ๋ฌด์Šจ ์ด์œ  ๋•Œ๋ฌธ์— ๋ฐœ์ƒํ–ˆ๋Š”์ง€๋Š” ์•„์ง๋„ ํ™•์‹ค์น˜ ์•Š์ง€๋งŒ...์•„๋ž˜์™€ ๊ฐ™์ด ํ•ด๊ฒฐํ–ˆ๋‹ค.

 

$ umount -l tmpfs

( tmpfs๋Š” /dev/shm์ด ๋งˆ์šดํŠธ๋œ ์ด๋ฆ„์ด๋‹ค. ์‰˜์—์„œ mount๋ช…๋ น์–ด๋กœ ํ™•์ธํ–ˆ์„๋•Œ ์ œ์ผ ์ขŒ์ธก์— ๋‚˜์˜ค๋Š” ์ด๋ฆ„ )

( -l (์†Œ๋ฌธ์žL)์˜ต์…˜์—†์ด ์–ธ๋งˆ์šดํŠธ์‹œํ‚ค๋ ค๊ณ  ํ–ˆ์„๋•Œ๋Š” busy๋ผ๊ณ  ๊ณ„์†๋œจ๊ธธ๋ž˜ ์˜ต์…˜์„ ์ฃผ๊ณ  ์–ธ๋งˆ์šดํŠธ ์‹œ์ผฐ๋‹ค. lazy umount ์˜ต์…˜์ด๋‹ค. )

 

$ mount -t tmpfs tmpfs /dev/shm

( ๋‹ค์‹œ ๋งˆ์šดํŠธ ํ•˜๊ธฐ ) 

 

๊ทธ๋ฆฌ๊ณ  sqlplus์— sysdba๋กœ connํ•ด์„œ 

SQL> startup

 

๊ฒŒ์ž„์˜ค๋ฒ„~!  

 

์ข€ ๋” ์ž์„ธํ•œ ์‚ฌํ•ญ์€ ์ด๊ณณ์„ ์ฐธ์กฐํ•˜์„ธ์š”. 

device is busy ๋ฌธ์ œ๋กœ umount๊ฐ€ ์•ˆ๋œ๋‹ค๋ฉด ์ด๊ณณ์„ ์ฐธ์กฐํ•˜์„ธ์š”. 


ํŒŒํ‹ฐ์…”๋‹๋œ ํ…Œ์ด๋ธ”์˜ ํ…Œ์ด๋ธ” ์ŠคํŽ˜์ด์Šค๋ฅผ ์˜ฎ๊ธฐ๋ ค๊ณ  ํ•  ๋•Œ ๋ฐœ์ƒํ–ˆ๋˜ ์˜ค๋ฅ˜.

SQL> alter table ํ…Œ์ด๋ธ”๋ช… move tablespace ํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค๋ช…

 

์ด๋Ÿฐ๊ฒฝ์šฐโ€‹์—๋Š” ์•„๋ž˜์™€ ๊ฐ™์€ ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•˜์ž.

 

SQL> alter table ํ…Œ์ด๋ธ”๋ช… modify default attributes tablespace ํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค๋ช…;

 

โ€‹๊ทธ๋ฆฌ๊ณ  ๋ถ€๊ฐ€์ ์œผ๋กœ ์ฒ˜๋ฆฌํ•ด์•ผ ํ•˜๋Š” ์ผ๋“ค์ด ์ข€ ์žˆ๋‹ค.

์ž์„ธํ•œ ์‚ฌํ•ญ์€ ์•„๋ž˜ ์˜๋ฌธ์„ ํ™•์ธํ•ด๋ณด๊ธธ ๋ฐ”๋ž€๋‹ค.

 

์ถœ์ฒ˜ : http://amit7oracledba.blogspot.kr/2013/03/move-partitioned-tables-to-different.html 

 

 

How to move partitioned tables to different tablespace

Yesterday I was trying to move a partitioned table to different tablespace using move command I got the following error:-

SQL> alter table partition move tablespace users parallel 10;
alter table partition move tablespace users parallel 10
            *
ERROR at line 1:
ORA-14511: cannot perform operation on a partitioned object


Default tablespace of partitioned table :-

SQL> select TABLE_NAME,PARTITIONING_TYPE,DEF_TABLESPACE_NAME from dba_part_tables where table_name='PARTITION';

TABLE_NAME                     PARTITIONING_TYPE                 DEF_TABLESPACE_NAME
----------------------------------------------------------------------------------------------------------------
PARTITION                          LIST                                               SYSTEM

Changing the default tablespace of Partition table. Now new partitions will be created in the new default tablespace, but old partitions will remain in the old default tablespace :-


SQL> alter table partition modify default attributes tablespace users;

Table altered.

SQL> select TABLE_NAME,PARTITIONING_TYPE,DEF_TABLESPACE_NAME from dba_part_tables where table_name='PARTITION';

TABLE_NAME                     PARTITIONING_TYPE                             DEF_TABLESPACE_NAME
----------------------------------------------------------------------------------------------------------------
PARTITION                          LIST                                               USERS

SQL> SELECT TABLE_NAME,PARTITION_NAME,TABLESPACE_NAME,NUM_ROWS FROM USER_TAB_PARTITIONS WHERE TABLE_NAME='PARTITION';

TABLE_NAME                     PARTITION_NAME                 TABLESPACE_NAME                  NUM_ROWS
----------------------------------------------------------------------------------------------------------------------------
PARTITION                          PAR1                                       SYSTEM
PARTITION                          PAR2                                       SYSTEM

SQL> SELECT * FROM PARTITION;

        ID NAME
---------- ---------------------
         1 d
         3 f
         7 y
         8 t

Analyzing above select statements, table partition have 4 records but records won't reflect in the NUM_ROWS column of USER_TAB_PARTITIONS  view. We need to gather the stats of Table "PARTITION" to reflect the records in NUM_ROWS column.


SQL> SHOW USER
USER is "SYS"
SQL> EXEC DBMS_STATS.gather_table_stats('SYS', 'PARTITION', granularity=>'ALL');

PL/SQL procedure successfully completed.


SQL> SELECT TABLE_NAME,PARTITION_NAME,TABLESPACE_NAME,NUM_ROWS FROM USER_TAB_PARTITIONS WHERE TABLE_NAME='PARTITION'

TABLE_NAME                     PARTITION_NAME                 TABLESPACE_NAME                  NUM_ROWS
-------------------------------------------------------------------------------------------------------------------------
PARTITION                         PAR1                                         SYSTEM                                  2
PARTITION                         PAR2                                         SYSTEM                                  2

Moving OLD partitions to different tablespace :-


SQL> select 'alter table ' || table_name || ' move partition ' || partition_name|| ' tablespace users parallel 10;' "PARTITION_MOVE_SCRIPT" from user_tab_partitions where table_name='PARTITION';

PARTITION_MOVE_SCRIPT
----------------------------------------------------------------------------------------------------------------------
alter table PARTITION move partition PAR1 tablespace users parallel 10;
alter table PARTITION move partition PAR2 tablespace users parallel 10;

After moving a table or partitioned table to different tablespace , indexes associated to the tablespace become unusable. We need to rebuild the associated indexes to make them usable.

Status of Indexes before moving a table :-


SQL>  select index_name,PARTITION_NAME,status from user_IND_PARTITIONS where TABLESPACE_NAME='SYSTEM';

INDEX_NAME                     PARTITION_NAME                 STATUS
----------------------------------------------------------------------------------------
PAR_IDX                             PAR1                                        USABLE
PAR_IDX                            PAR2                                         USABLE

 SQL> alter table PARTITION move partition PAR1 tablespace users parallel 10;

Table altered.

SQL> alter table PARTITION move partition PAR2 tablespace users parallel 10;

Table altered.

SQL>
SQL> SELECT TABLE_NAME,PARTITION_NAME,TABLESPACE_NAME,NUM_ROWS FROM USER_TAB_PARTITIONS WHERE TABLE_NAME='PARTITION';

TABLE_NAME                     PARTITION_NAME                 TABLESPACE_NAME                  NUM_ROWS
--------------------------------------------------------------------------------------------------------------------------
PARTITION                          PAR1                                        USERS                                   2
PARTITION                          PAR2                                        USERS                                   2

SQL> select index_name,PARTITION_NAME,status from user_IND_PARTITIONS where TABLESPACE_NAME='SYSTEM';

INDEX_NAME                     PARTITION_NAME                 STATUS
-----------------------------------------------------------------------------------------
PAR_IDX                              PAR1                                       UNUSABLE
PAR_IDX                              PAR2                                       UNUSABLE

It seems that the indexes becomes unusable. We need to rebuild the indexes to make them usable.

SQL> select 'alter index ' || a.index_name ||  ' rebuild partition ' || a.PARTITION_NAME || ' tablespace USERS parallel 10;' from user_ind_partitions a, user_tab_partitions b where a.partition_name=b.partition_name and b.table_name='PARTITION';


'ALTERINDEX'||A.INDEX_NAME||'REBUILDPARTITION'||A.PARTITION_NAME||'TABLESPACEUSERSPARALLEL10;'
-------------------------------------------------------------------------------------------------------------------------
alter index PAR_IDX rebuild partition PAR1 tablespace USERS parallel 10;
alter index PAR_IDX rebuild partition PAR2 tablespace USERS parallel 10;

SQL> select index_name,PARTITION_NAME,status from user_IND_PARTITIONS where TABLESPACE_NAME='USERS';

INDEX_NAME                     PARTITION_NAME                 STATUS
------------------------------------------------------------------------------------------
PAR_IDX                              PAR1                                        USABLE
PAR_IDX                              PAR2                                        USABLE

This way we can move a partitioned table having n number of partitions to different tablespace.


์ˆ˜๋ฐฑ๋งŒ๊ฑด์˜ ๋ฐ์ดํƒ€๋ฅผ ์ฒ˜๋ฆฌํ•˜๋‹ค๊ฐ€ ์ œ๋ชฉ๊ณผ ๊ฐ™์€ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค.

 

~~  ์ธ๋ฑ์Šค๋ฅผ 8192๋กœ  USERS ํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค์—์„œ ํ™•์žฅํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค

 

์ด์œ ์ธ ์ฆ‰์Šจ ์‚ฌ์šฉ์ž๊ฐ€ ํŠน์ • ํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค์—์„œ ๋ฐ์ดํƒ€๋ฅผ ๋”์ด์ƒ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์—†์–ด์„œ ๋‚˜๋Š” ์˜ค๋ฅ˜.

 

๋”ฐ๋ผ์„œ ์ด๋Ÿฐ ๊ฒฝ์šฐ ํ…Œ์ด๋ธ” ์ŠคํŽ˜์ด์Šค๋ฅผ ํ™•์žฅํ•ด์ฃผ๊ฑฐ๋‚˜ ๋ณ€๊ฒฝํ•ด์ฃผ๊ฑฐ๋‚˜ ํ•˜๋Š” ๋“ฑ๋“ฑ์˜ ์ž‘์—…์ด ํ•„์š”ํ•˜๋‹ค.

 

- ํŠน์ • ํ…Œ์ด๋ธ”์˜ ํ…Œ์ด๋ธ” ์ŠคํŽ˜์ด์Šค๋ฅผ ๋ณ€๊ฒฝํ•˜๋Š” ์ž‘์—…. 

alter table table_name move tablespace new_tablespace_name;  

 

- ์ธ๋ฑ์Šค์˜ ํ…Œ์ด๋ธ” ์ŠคํŽ˜์ด์Šค๋ฅผ ๋ณ€๊ฒฝํ•˜๋Š” ์ž‘์—….

alter index index_name rebuild tablespace new_tablespace_name;


๋‚ด ๊ณ„์ •์˜ ํ…Œ์ด๋ธ”๋“ค ์ค‘์—์„œ ํŒŒํ‹ฐ์…˜๋œ ํ…Œ์ด๋ธ”์˜ ๋ชฉ๋ก ๋ฐ ์ •๋ณด๋ฅผ ๋ณด๊ณ  ์‹ถ๋‹ค๋ฉด

SQL > select * from user_part_tables;

 

์ธ๋ฑ์Šค ์ •๋ณด๋Š”

SQL > select * from user_part_indexes;

 

dba๊ณ„์ •์œผ๋กœ ๋ชจ๋“  ์‚ฌ์šฉ์ž์˜ ํŒŒํ‹ฐ์…˜๋œ ํ…Œ์ด๋ธ”์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ๋ณด๊ณ  ์‹ถ๋‹ค๋ฉด

 

SQL > select * from user_part_tables;

 

์ธ๋ฑ์Šค ์ •๋ณด๋Š”

SQL > select * from dba_part_indexes;

 

์ข€ ๋” ์ž์„ธํ•œ ๋‚ด์šฉ์€ ์•„๋ž˜๋ฅผ ์ฐธ๊ณ ํ•˜๊ธฐ ๋ฐ”๋ž€๋‹ค. 

 

 

 

 

์ถœ์ฒ˜ : http://docs.oracle.com/cd/E18283_01/server.112/e16541/part_admin005.htm 

 

Viewing Information About Partitioned Tables and Indexes

The following views display information specific to partitioned tables and indexes:

ViewDescription
DBA_PART_TABLES

ALL_PART_TABLES

USER_PART_TABLES

DBA view displays partitioning information for all partitioned tables in the database. ALL view displays partitioning information for all partitioned tables accessible to the user. USER view is restricted to partitioning information for partitioned tables owned by the user.
DBA_TAB_PARTITIONS

ALL_TAB_PARTITIONS

USER_TAB_PARTITIONS

Display partition-level partitioning information, partition storage parameters, and partition statistics generated by the DBMS_STATS package or the ANALYZE statement.
DBA_TAB_SUBPARTITIONS

ALL_TAB_SUBPARTITIONS

USER_TAB_SUBPARTITIONS

Display subpartition-level partitioning information, subpartition storage parameters, and subpartition statistics generated by the DBMS_STATS package or the ANALYZE statement.
DBA_PART_KEY_COLUMNS

ALL_PART_KEY_COLUMNS

USER_PART_KEY_COLUMNS

Display the partitioning key columns for partitioned tables.
DBA_SUBPART_KEY_COLUMNS

ALL_SUBPART_KEY_COLUMNS

USER_SUBPART_KEY_COLUMNS

Display the subpartitioning key columns for composite-partitioned tables (and local indexes on composite-partitioned tables).
DBA_PART_COL_STATISTICS

ALL_PART_COL_STATISTICS

USER_PART_COL_STATISTICS

Display column statistics and histogram information for the partitions of tables.
DBA_SUBPART_COL_STATISTICS

ALL_SUBPART_COL_STATISTICS

USER_SUBPART_COL_STATISTICS

Display column statistics and histogram information for subpartitions of tables.
DBA_PART_HISTOGRAMS

ALL_PART_HISTOGRAMS

USER_PART_HISTOGRAMS

Display the histogram data (end-points for each histogram) for histograms on table partitions.
DBA_SUBPART_HISTOGRAMS

ALL_SUBPART_HISTOGRAMS

USER_SUBPART_HISTOGRAMS

Display the histogram data (end-points for each histogram) for histograms on table subpartitions.
DBA_PART_INDEXES

ALL_PART_INDEXES

USER_PART_INDEXES

Display partitioning information for partitioned indexes.
DBA_IND_PARTITIONS

ALL_IND_PARTITIONS

USER_IND_PARTITIONS

Display the following for index partitions: partition-level partitioning information, storage parameters for the partition, statistics collected by the DBMS_STATS package or the ANALYZE statement.
DBA_IND_SUBPARTITIONS

ALL_IND_SUBPARTITIONS

USER_IND_SUBPARTITIONS

Display the following information for index subpartitions: partition-level partitioning information, storage parameters for the partition, statistics collected by the DBMS_STATS package or the ANALYZE statement.
DBA_SUBPARTITION_TEMPLATES

ALL_SUBPARTITION_TEMPLATES

USER_SUBPARTITION_TEMPLATES

Display information about existing subpartition templates.

See Also:


์ถœ์ฒ˜ : http://docs.oracle.com/javase/7/docs/technotes/tools/share/jstat.html

 

SYNOPSIS

jstat [ generalOption | outputOptions vmid [interval[s|ms] [count]] ]

PARAMETERS

generalOption
A single general command-line option (-help or -options)
outputOptions
One or more output options, consisting of a single statOption, plus any of the -t, -h, and -J options.
vmid
Virtual machine identifier, a string indicating the target Java virtual machine (JVM). The general syntax is
[protocol:][//]lvmid[@hostname[:port]/servername]
The syntax of the vmid string largely corresponds to the syntax of a URI. The vmid can vary from a simple integer representing a local JVM to a more complex construction specifying a communications protocol, port number, and other implementation-specific values. See Virtual Machine Identifier for details.
interval[s|ms]
Sampling interval in the specified units, seconds (s) or milliseconds (ms). Default units are milliseconds. Must be a positive integer. If specified, jstat will produce its output at each interval.
count
Number of samples to display. Default value is infinity; that is, jstat displays statistics until the target JVM terminates or the jstat command is terminated. Must be a positive integer.

DESCRIPTION

The jstat tool displays performance statistics for an instrumented HotSpot Java virtual machine (JVM). The target JVM is identified by its virtual machine identifier, or vmid option described below.

NOTE: This utility is unsupported and may not be available in future versions of the JDK. It is not currently available on Windows 98 and Windows ME. platforms. 

VIRTUAL MACHINE IDENTIFIER

The syntax of the vmid string largely corresponds to the syntax of a URI:

[protocol:][//]lvmid[@hostname][:port][/servername]
protocol
The communications protocol. If the protocol is omitted and a hostname is not specified, the default protocol is a platform specific optimized local protocol. If the protocol is omitted and a hostname is specified, then the default protocol is rmi.
lvmid
The local virtual machine identifier for the target JVM. The lvmid is a platform-specific value that uniquely identifies a JVM on a system. The lvmid is the only required component of a virtual machine identifier. The lvmid is typically, but not necessarily, the operating system's process identifier for the target JVM process. You can use the jps command to determine the lvmid. Also, you can determine lvmid on Unix platforms with the ps command, and on Windows with the Windows Task Manager.
hostname
A hostname or IP address indicating the target host. If hostname is omitted, then the target host is the local host.
port
The default port for communicating with the remote server. If the hostname is omitted or the protocol specifies an optimized, local protocol, then port is ignored. Otherwise, treatment of the port parameter is implementation specific. For the default rmi protocol, the port indicates the port number for the rmiregistry on the remote host. If port is omitted, and protocol indicates rmi, then the default rmiregistry port (1099) is used.
servername
The treatment of this parameter depends on implementation. For the optimized local protocol, this field is ignored. For the rmi protocol, it represents the name of the RMI remote object on the remote host.

OPTIONS

The jstat command supports two types of options, general options and output options. General options cause jstat to display simple usage and version information. Output options determine the content and format of the statistical output. 

NOTE: All options, and their functionality are subject to change or removal in future releases.

GENERAL OPTIONS

If you specify one of the general options, you cannot specify any other option or parameter.

-help
Display help message.
-options
Display list of statistics options. See the Output Options section below.

OUTPUT OPTIONS

If you do not specify a general option, then you can specify output options. Output options determine the content and format of jstat's output, and consist of a single statOption, plus any of the other output options (-h, -t, and -J). The statOption must come first.

Output is formatted as a table, with columns are separated by spaces. A header row with titles describes the columns. Use the -h option to set the frequency at which the header is displayed. Column header names are generally consistent between the different options. In general, if two options provide a column with the same name, then the data source for the two columns are the same.

Use the -t option to display a time stamp column, labeled Timestamp as the first column of output. The Timestamp column contains the elapsed time, in seconds, since startup of the target JVM. The resolution of the time stamp is dependent on various factors and is subject to variation due to delayed thread scheduling on heavily loaded systems.

Use the interval and count parameters to determine how frequently and how many times, respectively, jstat displays its output.

NOTE: You are advised not to write scripts to parse jstat's output since the format may change in future releases. If you choose to write scripts that parse jstat output, expect to modify them for future releases of this tool.

-statOption
Determines the statistics information that jstat displays. The following table lists the available options. Use the -options general option to display the list of options for a particular platform installation.

OptionDisplays...
classStatistics on the behavior of the class loader.
compilerStatistics of the behavior of the HotSpot Just-in-Time compiler.
gcStatistics of the behavior of the garbage collected heap.
gccapacityStatistics of the capacities of the generations and their corresponding spaces.
gccauseSummary of garbage collection statistics (same as -gcutil), with the cause of the last and current (if applicable) garbage collection events.
gcnewStatistics of the behavior of the new generation.
gcnewcapacityStatistics of the sizes of the new generations and its corresponding spaces.
gcoldStatistics of the behavior of the old and permanent generations.
gcoldcapacityStatistics of the sizes of the old generation.
gcpermcapacityStatistics of the sizes of the permanent generation.
gcutilSummary of garbage collection statistics.
printcompilationHotSpot compilation method statistics.
-h n
Display a column header every n samples (output rows), where n is a positive integer. Default value is 0, which displays the column header above the first row of data.
-t
Display a timestamp column as the first column of output. The timestamp is the time since the start time of the target JVM.
-JjavaOption
Pass javaOption to the java application launcher. For example, -J-Xms48m sets the startup memory to 48 megabytes. For a complete list of options, see java - the Java application launcher

STATOPTIONS AND OUTPUT

The following tables summarize the columns that jstat outputs for each statOption

-class Option

Class Loader Statistics
ColumnDescription
LoadedNumber of classes loaded.
BytesNumber of Kbytes loaded.
UnloadedNumber of classes unloaded.
BytesNumber of Kbytes unloaded.
TimeTime spent performing class load and unload operations.

-compiler Option

HotSpot Just-In-Time Compiler Statistics
ColumnDescription
CompiledNumber of compilation tasks performed.
FailedNumber of compilation tasks that failed.
InvalidNumber of compilation tasks that were invalidated.
TimeTime spent performing compilation tasks.
FailedTypeCompile type of the last failed compilation.
FailedMethodClass name and method for the last failed compilation.

-gc Option

Garbage-collected heap statistics
ColumnDescription
S0CCurrent survivor space 0 capacity (KB).
S1CCurrent survivor space 1 capacity (KB).
S0USurvivor space 0 utilization (KB).
S1USurvivor space 1 utilization (KB).
ECCurrent eden space capacity (KB).
EUEden space utilization (KB).
OCCurrent old space capacity (KB).
OUOld space utilization (KB).
PCCurrent permanent space capacity (KB).
PUPermanent space utilization (KB).
YGCNumber of young generation GC Events.
YGCTYoung generation garbage collection time.
FGCNumber of full GC events.
FGCTFull garbage collection time.
GCTTotal garbage collection time.

-gccapacity Option

Memory Pool Generation and Space Capacities
ColumnDescription
NGCMNMinimum new generation capacity (KB).
NGCMXMaximum new generation capacity (KB).
NGCCurrent new generation capacity (KB).
S0CCurrent survivor space 0 capacity (KB).
S1CCurrent survivor space 1 capacity (KB).
ECCurrent eden space capacity (KB).
OGCMNMinimum old generation capacity (KB).
OGCMXMaximum old generation capacity (KB).
OGCCurrent old generation capacity (KB).
OCCurrent old space capacity (KB).
PGCMNMinimum permanent generation capacity (KB).
PGCMXMaximum Permanent generation capacity (KB).
PGCCurrent Permanent generation capacity (KB).
PCCurrent Permanent space capacity (KB).
YGCNumber of Young generation GC Events.
FGCNumber of Full GC Events.

-gccause Option

This option displays the same summary of garbage collection statistics as the -gcutil option, but includes the causes of the last garbage collection event and (if applicable) the current garbage collection event. In addition to the columns listed for -gcutil, this option adds the following columns:

Garbage Collection Statistics, Including GC Events
ColumnDescription
LGCCCause of last Garbage Collection.
GCCCause of current Garbage Collection.

-gcnew Option

New Generation Statistics
ColumnDescription
S0CCurrent survivor space 0 capacity (KB).
S1CCurrent survivor space 1 capacity (KB).
S0USurvivor space 0 utilization (KB).
S1USurvivor space 1 utilization (KB).
TTTenuring threshold.
MTTMaximum tenuring threshold.
DSSDesired survivor size (KB).
ECCurrent eden space capacity (KB).
EUEden space utilization (KB).
YGCNumber of young generation GC events.
YGCTYoung generation garbage collection time.

-gcnewcapacity Option

New Generation Space Size Statistics
ColumnDescription
NGCMN
Minimum new generation capacity (KB).
NGCMX Maximum new generation capacity (KB).
NGC Current new generation capacity (KB).
S0CMXMaximum survivor space 0 capacity (KB).
S0CCurrent survivor space 0 capacity (KB).
S1CMXMaximum survivor space 1 capacity (KB).
S1CCurrent survivor space 1 capacity (KB).
ECMXMaximum eden space capacity (KB).
ECCurrent eden space capacity (KB).
YGCNumber of young generation GC events.
FGCNumber of Full GC Events.

-gcold Option

Old and Permanent Generation Statistics
ColumnDescription
PCCurrent permanent space capacity (KB).
PUPermanent space utilization (KB).
OCCurrent old space capacity (KB).
OUold space utilization (KB).
YGCNumber of young generation GC events.
FGCNumber of full GC events.
FGCTFull garbage collection time.
GCTTotal garbage collection time.

-gcoldcapacity Option

Old Generation Statistics
ColumnDescription
OGCMNMinimum old generation capacity (KB).
OGCMXMaximum old generation capacity (KB).
OGCCurrent old generation capacity (KB).
OCCurrent old space capacity (KB).
YGCNumber of young generation GC events.
FGCNumber of full GC events.
FGCTFull garbage collection time.
GCTTotal garbage collection time.

-gcpermcapacity Option

Permanent Generation Statistics
ColumnDescription
PGCMNMinimum permanent generation capacity (KB).
PGCMXMaximum permanent generation capacity (KB).
PGCCurrent permanent generation capacity (KB).
PCCurrent permanent space capacity (KB).
YGCNumber of young generation GC events.
FGCNumber of full GC events.
FGCTFull garbage collection time.
GCTTotal garbage collection time.

-gcutil Option

Summary of Garbage Collection Statistics
ColumnDescription
S0Survivor space 0 utilization as a percentage of the space's current capacity.
S1Survivor space 1 utilization as a percentage of the space's current capacity.
EEden space utilization as a percentage of the space's current capacity.
OOld space utilization as a percentage of the space's current capacity.
PPermanent space utilization as a percentage of the space's current capacity.
YGCNumber of young generation GC events.
YGCTYoung generation garbage collection time.
FGCNumber of full GC events.
FGCTFull garbage collection time.
GCTTotal garbage collection time.

-printcompilation Option

HotSpot Compiler Method Statistics
ColumnDescription
CompiledNumber of compilation tasks performed by the most recently compiled method.
SizeNumber of bytes of bytecode of the most recently compiled method.
TypeCompilation type of the most recently compiled method.
MethodClass name and method name identifying the most recently compiled method. Class name uses "/" instead of "." as namespace separator. Method name is the method within the given class. The format for these two fields is consistent with the HotSpot - XX:+PrintComplation option.

EXAMPLES

This section presents some examples of monitoring a local JVM with a lvmid of 21891.

Using the gcutil option

This example attaches to lvmid 21891 and takes 7 samples at 250 millisecond intervals and displays the output as specified by the -gcutil option.

jstat -gcutil 21891 250 7
S0 S1 E O P YGC YGCT FGC FGCT GCT
12.44 0.00 27.20 9.49 96.70 78 0.176 5 0.495 0.672
12.44 0.00 62.16 9.49 96.70 78 0.176 5 0.495 0.672
12.44 0.00 83.97 9.49 96.70 78 0.176 5 0.495 0.672
0.00 7.74 0.00 9.51 96.70 79 0.177 5 0.495 0.673
0.00 7.74 23.37 9.51 96.70 79 0.177 5 0.495 0.673
0.00 7.74 43.82 9.51 96.70 79 0.177 5 0.495 0.673
0.00 7.74 58.11 9.51 96.71 79 0.177 5 0.495 0.673

The output of this example shows that a young generation collection occurred between the 3rd and 4th sample. The collection took 0.001 seconds and promoted objects from the eden space (E) to the old space (O), resulting in an increase of old space utilization from 9.49% to 9.51%. Before the collection, the survivor space was 12.44% utilized, but after this collection it is only 7.74% utilized.

Repeating the column header string

This example attaches to lvmid 21891 and takes samples at 250 millisecond intervals and displays the output as specified by -gcutil option. In addition, it uses the -h3 option to output the column header after every 3 lines of data.

jstat -gcnew -h3 21891 250
S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT
64.0 64.0 0.0 31.7 31 31 32.0 512.0 178.6 249 0.203
64.0 64.0 0.0 31.7 31 31 32.0 512.0 355.5 249 0.203
64.0 64.0 35.4 0.0 2 31 32.0 512.0 21.9 250 0.204
S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT
64.0 64.0 35.4 0.0 2 31 32.0 512.0 245.9 250 0.204
64.0 64.0 35.4 0.0 2 31 32.0 512.0 421.1 250 0.204
64.0 64.0 0.0 19.0 31 31 32.0 512.0 84.4 251 0.204
S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT
64.0 64.0 0.0 19.0 31 31 32.0 512.0 306.7 251 0.204

In addition to showing the repeating header string, this example shows that between the 2nd and 3rd samples, a young GC occurred. Its duration was 0.001 seconds. The collection found enough live data that the survivor space 0 utilization (S0U) would would have exceeded the desired survivor Size (DSS). As a result, objects were promoted to the old generation (not visible in this output), and the tenuring threshold (TT) was lowered from 31 to 2.

Another collection occurs between the 5th and 6th samples. This collection found very few survivors and returned the tenuring threshold to 31.

Including a time stamp for each sample

This example attaches to lvmid 21891 and takes 3 samples at 250 millisecond intervals. The -t option is used to generate a time stamp for each sample in the first column.

jstat -gcoldcapacity -t 21891 250 3
Timestamp OGCMN OGCMX OGC OC YGC FGC FGCT GCT
150.1 1408.0 60544.0 11696.0 11696.0 194 80 2.874 3.799
150.4 1408.0 60544.0 13820.0 13820.0 194 81 2.938 3.863
150.7 1408.0 60544.0 13820.0 13820.0 194 81 2.938 3.863

The Timestamp column reports the elapsed time in seconds since the start of the target JVM. In addition, the -gcoldcapacity output shows the old generation capacity (OGC) and the old space capacity (OC) increasing as the heap expands to meet allocation and/or promotion demands. The old generation capacity (OGC) has grown to from 11696 KB to 13820 KB after the 81st Full GC (FGC). The maximum capacity of the generation (and space) is 60544 KB (OGCMX), so it still has room to expand.

Monitor instrumentation for a remote JVM

This example attaches to lvmid 40496 on the system named remote.domain using the -gcutil option, with samples taken every second indefinitely.

jstat -gcutil 40496@remote.domain 1000
... output omitted

The lvmid is combined with the name of the remote host to construct a vmid of 40496@remote.domain. This vmid results in the use of the rmi protocol to communicate to the default jstatd server on the remote host. The jstatd server is located using the rmiregistry on remote.domain that is bound to the default rmiregistry port (port 1099).

SEE ALSO

  • java - the Java Application Launcher
  • jps - the Java Process Status Application
  • jstatd - the jvmstat daemon
  • rmiregistry - the Java Remote Object Registry


์ถœ์ฒ˜ : http://a07274.tistory.com/227

( ์˜ค๋ผํด ์‚ฌ์ดํŠธ์—์„œ ์ข€ ๋” ์ž์„ธํ•œ ์‚ฌํ•ญ์„ ํ™•์ธํ•˜๊ณ  ์‹ถ์€ ๋ถ„๋“ค์€ ์ด๊ณณ์„ ์ด์šฉํ•˜๋ฉด๋œ๋‹ค. ) 

I. ์˜ค๋ผํด ํŒŒํ‹ฐ์…˜ ์ •์˜

1. ํŒŒํ‹ฐ์…˜ ๊ฐœ์š”
์˜ค๋Š˜๋‚  ๊ธฐ์—…์—์„œ ๊ด€๋ฆฌํ•˜๋Š” ๋ฐ์ดํ„ฐ๋Š” ์ˆ˜๋ฐฑํ…Œ๋ผ ๋ฐ”์ดํŠธ์— ์ด๋ฅด๋Š” ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋ฅผ ๊ด€๋ฆฌํ•œ๋‹ค.
ํ•˜์ง€๋งŒ ์ด๋Ÿฐ ๋ฐ์ดํ„ฐ๋“ค ์ค‘ ๋ช‡๋ช‡์˜ Big Transaction Table์ด ๊ฑฐ์˜ ๋ชจ๋“  ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๊ณ 
๋‚˜๋จธ์ง€ ํ…Œ์ด๋ธ”๋“ค์€ ์ด Big Transaction Table์„ ๊ฒฝ์œ ํ•˜์—ฌ ์•ก์„ธ์Šค ํ•˜๋Š” ์šฉ๋„๋กœ ์‚ฌ์šฉ๋œ๋‹ค.

์ด๋ ‡๊ฒŒ ๋ฐ์ดํ„ฐ ํฌ๊ธฐ๋„ ํฌ๊ณ  ์ค‘์š”ํ•œ Big Transaction Table์„ ๊ด€๋ฆฌํ•˜๋Š” ๋ถ€๋ถ„์—์„œ Troubleshooting์ด
๋ฐœ์ƒ๋  ๊ฒฝ์šฐ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์˜ ์„ฑ๋Šฅ ๋ฐ ๊ด€๋ฆฌ์ž‘์—…์— ์‹ฌ๊ฐํ•œ ์˜ํ–ฅ์„ ๋ฐ›์„ ์ˆ˜ ์žˆ๋‹ค.

์ด๋Ÿฌํ•œ ๋ฆฌ์Šคํฌ๊ฐ€ ์žˆ๋Š” Big Transaction Table์„ ๋ณด๋‹ค ํšจ์œจ์ ์œผ๋กœ ๊ด€๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด Table์„
์ž‘์€ ๋‹จ์œ„๋กœ ๋‚˜๋ˆ”์œผ๋กœ์จ ๋ฐ์ดํ„ฐ ์•ก์„ธ์Šค ์ž‘์—…์˜ ์„ฑ๋Šฅ ํ–ฅ์ƒ์„ ์œ ๋„ํ•˜๊ณ  ๋ฐ์ดํ„ฐ ๊ด€๋ฆฌ๋ฅผ ๋ณด๋‹ค
์ˆ˜์›”ํ•˜๊ฒŒ ํ•˜๊ณ ์ž ํ•˜๋Š” ๊ฐœ๋…์ด๋‹ค.

2. ํŒŒํ‹ฐ์…˜ ํ…Œ์ด๋ธ”์˜ ์žฅ์ 
1) ๊ฐœ์„ ๋œ ๊ฐ€์šฉ์„ฑ
- ํŒŒํ‹ฐ์…˜์€ ๋…๋ฆฝ์ ์œผ๋กœ ๊ด€๋ฆฌ๋œ๋‹ค.
- Backup and Restore๋ฅผ ํŒŒํ‹ฐ์…˜๋ณ„๋กœ ์ž‘์—…ํ•  ์ˆ˜ ์žˆ๋‹ค.
- ๊ฐ™์€ ํ…Œ์ด๋ธ”์—์„œ Unavailableํ•œ ํŒŒํ‹ฐ์…˜์€ ๋‹ค๋ฅธ ํŒŒํ‹ฐ์…˜์— ์˜ํ–ฅ์„ ์ฃผ์ง€ ์•Š๋Š”๋‹ค.
2) ๊ด€๋ฆฌ์˜ ์šฉ์ด์„ฑ
- ์‚ฌ์šฉ์ž๊ฐ€ ์ง€์ •ํ•œ ๊ฐ’์œผ๋กœ ํŒŒํ‹ฐ์…˜์ด ๊ฐ€๋Šฅํ•˜๋‹ค.
- ํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค๊ฐ„์— ํŒŒํ‹ฐ์…˜ ์ด๋™์ด ๊ฐ€๋Šฅํ•˜๋‹ค.
- ํŒŒํ‹ฐ์…˜ ๋ ˆ๋ฒจ์—์„œ Select, Delete, Update๊ฐ€ ๊ฐ€๋Šฅํ•˜๋‹ค.
3) ๊ฐœ์„ ๋œ ์„ฑ๋Šฅ
- ๋ฐ์ดํ„ฐ๋ฅผ ์•ก์„ธ์Šคํ•  ๋•Œ ์•ก์„ธ์Šคํ•˜๋Š” ๋ฒ”์œ„๋ฅผ ์ค„์—ฌ ํผํฌ๋จผ์Šค ํ–ฅ์ƒ์„ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ๋‹ค.
- RAC(Real Application Clusters) ํ™˜๊ฒฝ์—์„œ ์ธ์Šคํ„ด์Šค๊ฐ„ Block Contention์„ ๊ฐ์†Œ์‹œํ‚จ๋‹ค.

3. ํŒŒํ‹ฐ์…˜ ํ…Œ์ด๋ธ” ์‚ฌ์šฉ์‹œ ์ฃผ์˜ํ•  ์ 
1) ๊ด€๋ฆฌ์ ์ธ ๊ด€์ 
- ํ•˜๋‚˜์˜ ํ…Œ์ด๋ธ”์„ ์„ธ๋ถ„ํ™”ํ•˜์—ฌ ๊ด€๋ฆฌํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋ณด๋‹ค ์„ธ์‹ฌํ•œ ๊ด€๋ฆฌ๊ฐ€ ์š”๊ตฌ๋œ๋‹ค.
- ํŒŒํ‹ฐ์…˜์„ ์ž˜ ๋ชป ๊ตฌ์„ฑ ๋˜๋Š” ๊ด€๋ฆฌํ•˜์—ฌ IU(Index Unusable)์— ๋น ์ง€๋Š” ๊ฒƒ์„ ์ฃผ์˜ํ•ด์•ผ ํ•œ๋‹ค.
2) ์‚ฌ์šฉํ•˜๋Š” ๊ด€์ 
- ํŒŒํ‹ฐ์…˜ ํ‚ค๋กœ ๋‚˜๋ˆ„์–ด์ ธ ์žˆ๋Š” ํ…Œ์ด๋ธ”์— ํŒŒํ‹ฐ์…˜ ํ‚ค๋ฅผ ์กฐ๊ฑด์œผ๋กœ ์ฃผ์ง€ ์•Š์•„ ์ „์ฒด ํŒŒํ‹ฐ์…˜์„ ์•ก์„ธ์Šคํ•˜์ง€
์•Š๋„๋ก ์ฃผ์˜ํ•ด์•ผ ํ•œ๋‹ค.

4. ํŒŒํ‹ฐ์…˜ ํ…Œ์ด๋ธ”์˜ ํŠน์ง•
- ํŒŒํ‹ฐ์…˜ ํ…Œ์ด๋ธ”์€ ํŒŒํ‹ฐ์…˜ ํ‚ค ๊ฐ’์— ์˜ํ•ด ๊ตฌ์„ฑ๋˜๋ฉฐ, ํ•œ ํ…Œ์ด๋ธ” ๋‹น ๊ฐ€๋Šฅํ•œ ํŒŒํ‹ฐ์…˜์€ ์ด๋ก ์ ์œผ๋กœ 65,535๊ฐœ๋ฅผ
์ง€์›ํ•˜๋‚˜ ์‹ค์งˆ์ ์œผ๋กœ๋Š” 10,000๊ฐœ๊นŒ์ง€๋งŒ ์ƒ์„ฑ ๊ฐ€๋Šฅํ•˜๋‹ค(Oracle Ver 10.2.0.3 ํ…Œ์ŠคํŠธ)


- ๋ชจ๋“  ํŒŒํ‹ฐ์…˜ ํ…Œ์ด๋ธ”(๋˜๋Š” ์ธ๋ฑ์Šค)๋Š” ๊ฐ™์€ Logical Attribute๋ฅผ ๊ฐ€์ ธ์•ผ ํ•œ๋‹ค.
Ex) Columns, Data Types, Constraints...


- ๋ชจ๋“  ํŒŒํ‹ฐ์…˜ ํ…Œ์ด๋ธ”(๋˜๋Š” ์ธ๋ฑ์Šค)๋Š” ๋‹ค๋ฅธ Physical Attribute๋ฅผ ๊ฐ€์ ธ์•ผ ํ•œ๋‹ค.
Ex) PCTFREE, PCTUSED, INITTRANS, MAXTRANS, TABLESPACE, STORAGE...


- ํŒŒํ‹ฐ์…˜ ํ…Œ์ด๋ธ”์€ 'KEY', 'VALUES LESS THAN Literal', 'Physical Attributes'๋กœ ๊ตฌ์„ฑ๋œ๋‹ค.


- 'VALUES LESS THAN Literal' ์ ˆ์—์„œ 'Literal' ๊ฐ’์—๋Š” SQL Function์„ ์ง€์›ํ•œ๋‹ค.


- Composite Column ๊ตฌ์„ฑ์€ 16๊ฐœ๊นŒ์ง€ ๊ฐ€๋Šฅํ•˜๋‹ค.

II. ํŒŒํ‹ฐ์…˜ ์ข…๋ฅ˜

1. Oracle ๋ฒ„์ „์— ๋”ฐ๋ฅธ ํŒŒํ‹ฐ์…˜
1) Oracle Ver 7.3
- Partition View๋ฅผ ์ฒ˜์Œ์œผ๋กœ ๋„์ž…ํ•˜์˜€๋‹ค.
- ๋‹น์‹œ Partition View๋Š” ํฐ ํ…Œ์ด๋ธ”์„ ๋™์ผํ•œ ํ…œํ”Œ๋ฆฟ์„ ๊ฐ€์ง„ ์—ฌ๋Ÿฌ ๊ฐœ์˜ ๋‹ค๋ฅธ ํ…Œ์ด๋ธ”๋กœ ๋ถ„ํ• ํ•˜๊ณ 
UNION ALL์„ ์‚ฌ์šฉํ•˜์—ฌ View๋กœ ๋ฌถ์€ ํ˜•ํƒœ์ด๋‹ค.
- ๊ทธ๋Ÿฌ๋‚˜ ์ด ๋ฐฉ์‹์€ ๊ด€๋ฆฌ์˜ ์–ด๋ ค์›€, ํ™œ์šฉ์„ฑ์˜ ๋ถ€์กฑ, ์„ฑ๋Šฅ๋“ฑ์— ๋Œ€ํ•œ ์ด์Šˆ๋กœ ์ธํ•˜์—ฌ Oracle Ver 9i์—์„œ๋Š”
๋”์ด์ƒ ์ง€์›ํ•˜์ง€ ์•Š๋Š”๋‹ค.


2) Oracle Ver 8.0
- ์ปฌ๋Ÿผ ๊ฐ’์˜ Range ๊ธฐ๋ฐ˜์œผ๋กœ ๋œ Range Partition์ด ์ตœ์ดˆ๋กœ ๋„์ž…๋˜์—ˆ๊ณ , ๋น„๋กœ์„œ Partition์˜ ๋ชจ์Šต์„ ๊ฐ–์ถ”์—ˆ๋‹ค.
- ๊ฐ ํŒŒํ‹ฐ์…˜์€ ๊ฐ๊ธฐ ๋‹ค๋ฅธ ํ…Œ์ด๋ธ” ์ŠคํŽ˜์ด์Šค, Segment์— ์ €์žฅ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.


3) Oracle Ver 8i
- ์ปฌ๋Ÿผ ๊ฐ’์˜ Hash ๊ธฐ๋ฐ˜์œผ๋กœ ๋œ hash partition๊ณผ, Sub Partition์„ ํ•  ์ˆ˜ ์žˆ๋Š” Composite Partition์ด ์ถ”๊ฐ€๋˜์—ˆ๋‹ค.
- ์ด ๋‹น์‹œ Composite Partition์€ Range-Hash๋กœ๋งŒ ๊ตฌ์„ฑ ๊ฐ€๋Šฅํ•จ.


4) Oracle Ver 9i
- ๋ฆฌ์ŠคํŠธ ๊ฐ’์œผ๋กœ ํŒŒํ‹ฐ์…˜์„ ํ•  ์ˆ˜ ์žˆ๋Š” List Partition์ด ์ถ”๊ฐ€๋˜์—ˆ๋‹ค.
- Composite Partition์—์„œ๋Š” Range-Hash ์ด์™ธ์— Range-List๊ฐ€ ์ถ”๊ฐ€ ์ง€์›๋˜์—ˆ๋‹ค.


5) Oracle Ver 10g
- IOT ํŒŒํ‹ฐ์…˜์ด ์ถ”๊ฐ€๋˜์—ˆ๋‹ค.


6) Oracle Ver 11g
- Composite Partition์—์„œ ํ™•์žฅ๋œ Extended Composite Partition์ด ์ง€์›๋œ๋‹ค.
-> Range-Range, List-Range, List-Hash, List-List
- Reference Partition ์ถ”๊ฐ€
- Interval Partition ์ถ”๊ฐ€
- System Partition ์ถ”๊ฐ€
- Virtual Column Partition ์ถ”๊ฐ€

2. Partition Table
1) Range Partition
- Column Value์˜ ๋ฒ”์œ„๋ฅผ ๊ธฐ์ค€์œผ๋กœ ํ•˜์—ฌ ํ–‰์„ ๋ถ„ํ• ํ•˜๋Š” ํ˜•ํƒœ์ด๋‹ค.
- Range Partition์—์„œ Table์€ ๋‹จ์ง€ ๋…ผ๋ฆฌ์ ์ธ ๊ตฌ์กฐ์ด๋ฉฐ ์‹ค์ œ ๋ฐ์ดํ„ฐ๊ฐ€ ๋ฌผ๋ฆฌ์ ์œผ๋กœ ์ €์žฅ๋˜๋Š” ๊ณณ์€
Partition์œผ๋กœ ๋‚˜๋ˆ„์–ด์ง„ Tablespace์— ์ €์žฅ์ด ๋œ๋‹ค.
- PARTITION BY RANGE ( column_list ) : ๊ธฐ๋ณธ Table์—์„œ ์–ด๋Š Column์„ ๊ธฐ์ค€์œผ๋กœ ๋ถ„ํ• ํ• ์ง€๋ฅผ ์ •ํ•จ.
VALUES LESS THAN ( value_list ) : ๊ฐ Partition์ด ์–ด๋–ค ๊ฐ’์˜ ๋ฒ”์œ„๋ฅผ ํฌํ•จ ํ• ์ง€ Upper Bound๋ฅผ ์ •ํ•จ.
- ๊ตฌ๋ฌธ Sample
CREATE TABLE SALES_DATA_2008
(
COLUMN_1 NUMBER NOT NULL,
COLUMN_2 VARCHAR2(4),
COLUMN_3 VARCHAR2(4),
COLUMN_4 VARCHAR2(2),
COLUMN_5 VARCHAR2(2),
COLUMN_6 NUMBER
)
TABLESPACE TABLE_SPACE_DATA_1
PCTFREE 5
PCTUSED 40
INITRANS 11
MAXTRANS 255
STORAGE
(
INITIAL 2048K
NEXT 1024K
PCTINCREASE 0
MINEXTENTS 1
MAXEXTENTS 121
)
PARTITION BY RANGE ( COLUMN_3, COLUMN_4, COLUMN_5 )
(
PARTITION P_200801 VALUES LESS THAN ('2008', '04', '01' ),
PARTITION P_200802 VALUES LESS THAN ('2008', '07', '01' ),
PARTITION P_200803 VALUES LESS THAN ('2008', '10', '01' ),
PARTITION P_200804 VALUES LESS THAN ('2009', '01', '01' ),
PARTITION P_5 VALUES LESS THAN (MAXVALUE)
TABLESPACE TABLE_SPACE_DATA_2
PCTFREE 5
PCTUSED 40
INITRANS 11
MAXTRANS 255
STORAGE
(
INITIAL 1M
NEXT 1M
PCTINCREASE 0
MINEXTENTS 1
MAXEXTENTS 121
);

2) Hash Partition
- Partitioning column์˜ Partitioning Key ๊ฐ’์— Hash ํ•จ์ˆ˜๋ฅผ ์ ์šฉํ•˜์—ฌ Data๋ฅผ ๋ถ„ํ• ํ•˜๋Š” ๋ฐฉ์‹.
- ๋ฐ์ดํ„ฐ ์ด๋ ฅ๊ด€๋ฆฌ์˜ ๋ชฉ์  ๋ณด๋‹ค ์„ฑ๋Šฅ ํ–ฅ์ƒ์˜ ๋ชฉ์ ์œผ๋กœ ๋‚˜์˜จ ๊ฐœ๋…์ด๋‹ค.
Hash Partition์€ Range Partition์—์„œ ๋ฒ”์œ„๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ๋‚˜๋ˆ„์—ˆ์„ ๊ฒฝ์šฐ ํŠน์ • ๋ฒ”์œ„์— ๋ถ„ํฌ๋„๊ฐ€ ๋ชฐ๋ ค์„œ
- ๊ฐ๊ธฐ Size๊ฐ€ ๋‹ค๋ฅด๊ฒŒ ๋˜๋Š” ๊ฒƒ์„ ๋ณด์™„ํ•˜์—ฌ, ์ผ์ •ํ•œ ๋ถ„ํฌ๋ฅผ ๊ฐ€์ง„ ํŒŒํ‹ฐ์…˜์œผ๋กœ ๋‚˜๋ˆ„๊ณ  ๊ท ๋“ฑํ•œ ๋ฐ์ดํ„ฐ ๋ถ„ํฌ๋„๋ฅผ
์ด์šฉํ•œ ๋ณ‘๋ ฌ์ฒ˜๋ฆฌ๋กœ ํผํฌ๋จผ์Šค๋ฅผ ๋ณด๋‹ค ํ–ฅ์ƒ์‹œํ‚ฌ ์ˆ˜ ์žˆ๋‹ค.
- Hash Partition์—์„œ Table์€ ๋‹จ์ง€ ๋…ผ๋ฆฌ์ ์ธ ๊ตฌ์กฐ์ด๋ฉฐ ์‹ค์ œ ๋ฐ์ดํ„ฐ๊ฐ€ ๋ฌผ๋ฆฌ์ ์œผ๋กœ ์ €์žฅ๋˜๋Š” ๊ณณ์€
Partition์œผ๋กœ ๋‚˜๋ˆ„์–ด์ง„ Tablespace์— ์ €์žฅ์ด ๋œ๋‹ค.
- ๊ตฌ๋ฌธ Sample
CREATE TABLE SALES_DATA_2008
(
COLUMN_1 NUMBER NOT NULL,
COLUMN_2 VARCHAR2(4),
COLUMN_3 VARCHAR2(4),
COLUMN_4 VARCHAR2(2),
COLUMN_5 VARCHAR2(2),
COLUMN_6 NUMBER
)
TABLESPACE TABLE_SPACE_DATA_1
PCTFREE 5
PCTUSED 40
INITRANS 11
MAXTRANS 255
STORAGE
(
INITIAL 2048K
NEXT 1024K
PCTINCREASE 0
MINEXTENTS 1
MAXEXTENTS 121
)
PARTITION BY HASH ( COLUMN_3, COLUMN_4, COLUMN_5 )
(
PARTITION P_200801,
PARTITION P_200802,
PARTITION P_200803,
PARTITION P_200804,
PARTITION P_5 VALUES LESS THAN (MAXVALUE)
)
);

3) Composite(Sub) Partition
- ํŒŒํ‹ฐ์…˜์˜ ์ปฌ๋Ÿผ์„ Main-Sub ๊ด€๊ณ„๋กœ ๋‚˜๋ˆ„์–ด ๋ถ„ํ• ํ•˜๋Š” ๋ฐฉ์‹.
- Composite Partition์ด ์•„๋‹Œ ๋‹ค๋ฅธ ํŒŒํ‹ฐ์…˜์—์„œ ๋ฌผ๋ฆฌ์ ์ธ ๋ฐ์ดํ„ฐ๊ฐ€ ์ €์žฅ๋˜๋Š” ๊ณณ์€ Table์ด ์•„๋‹Œ
Partition Table์— ์ €์žฅ์ด ๋˜๋Š” ๊ฒƒ์ฒ˜๋Ÿผ, Composite Partition์—์„œ๋Š” Main Partition์ด ์•„๋‹Œ
Sub Partition์— ์ €์žฅ๋œ๋‹ค.
- Composite Partition์˜ ์กฐํ•ฉ ๊ตฌ์„ฑ์€ Oracle์˜ ๋ฒ„์ „์ด ์˜ฌ๋ผ๊ฐˆ์ˆ˜๋ก ์กฐํ•ฉํ•˜๋Š” ๋ฐฉ์‹์„ ๋‹ค์–‘ํ•˜๊ฒŒ ์ง€์›ํ•œ๋‹ค.




- ๊ตฌ๋ฌธ Sample
CREATE TABLE SALES_DATA_2008
(
COLUMN_1 NUMBER NOT NULL,
COLUMN_2 VARCHAR2(4),
COLUMN_3 VARCHAR2(4),
COLUMN_4 VARCHAR2(2),
COLUMN_5 VARCHAR2(2),
COLUMN_6 NUMBER
)
TABLESPACE TABLE_SPACE_DATA_1
PCTFREE 5
PCTUSED 40
INITRANS 11
MAXTRANS 255
STORAGE
(
INITIAL 2048K
NEXT 1024K
PCTINCREASE 0
MINEXTENTS 1
MAXEXTENTS 121
)
PARTITION BY RANGE ( COLUMN_3, COLUMN_4 )
SUBPARTITION BY HASH ( COLUMN_5 )
(PARTITION P_200801 VALUES LESS THAN ('2008', '04'),
PARTITION P_200802 VALUES LESS THAN ('2008', '07'),
PARTITION P_200803 VALUES LESS THAN ('2008', '10')
(SUBPARTITIONS P_200803_S1 TABLESPACE TABLE_SPACE_DATA_1_1,
SUBPARTITIONS P_200803_S2 TABLESPACE TABLE_SPACE_DATA_1_2,
SUBPARTITIONS P_200803_S3 TABLESPACE TABLE_SPACE_DATA_1_3,
SUBPARTITIONS P_200803_S4 TABLESPACE TABLE_SPACE_DATA_1_4,
SUBPARTITIONS P_200803_S5 TABLESPACE TABLE_SPACE_DATA_1_5,
SUBPARTITIONS P_200803_S6 TABLESPACE TABLE_SPACE_DATA_1_6,
SUBPARTITIONS P_200803_S7 TABLESPACE TABLE_SPACE_DATA_1_7,
SUBPARTITIONS P_200803_S8 TABLESPACE TABLE_SPACE_DATA_1_8
),
PARTITION P_200804 VALUES LESS THAN ('2009', '01')
);

4) List Partition
- Partitioning column์˜ ํŠน์ • ๊ฐ’์œผ๋กœ ๋ถ„ํ• ํ•˜๋Š” ๋ฐฉ์‹
- ๋ฐ์ดํ„ฐ ๋ถ„ํฌ๋„๊ฐ€ ๋‚ฎ์ง€ ์•Š๊ณ , ๊ท ๋“ฑํ•˜๊ฒŒ ๋ถ„ํฌ๋˜์–ด ์žˆ์„ ๋•Œ ์œ ์šฉํ•˜๋‹ค.
- Composite Partition์—์„œ 'Range-List'์ผ ๊ฒฝ์šฐ ๊ทธ ํšจ์œจ์ด ๋”์šฑ ๋†’์•„์ง„๋‹ค.
- ๋‹ค๋ฅธ ํŒŒํ‹ฐ์…˜ ๋ฐฉ์‹์ฒ˜๋Ÿผ ๋‹ค์ค‘ ์ปฌ๋Ÿผ์„ ์ง€์›ํ•˜์ง€ ์•Š๊ณ  ๋‹จ์ผ ์ปฌ๋Ÿผ๋งŒ ๊ฐ€๋Šฅํ•˜๋‹ค.
- ๊ตฌ๋ฌธ Sample
CREATE TABLE SALES_DATA_2008
(
COLUMN_1 NUMBER NOT NULL,
COLUMN_2 VARCHAR2(4),
COLUMN_3 VARCHAR2(4),
COLUMN_4 VARCHAR2(2),
COLUMN_5 VARCHAR2(2),
COLUMN_6 NUMBER
)
TABLESPACE TABLE_SPACE_DATA_1
PCTFREE 5
PCTUSED 40
INITRANS 11
MAXTRANS 255
STORAGE
(
INITIAL 2048K
NEXT 1024K
PCTINCREASE 0
MINEXTENTS 1
MAXEXTENTS 121
)
PARTITION BY LIST(COLUMN_2)
(
PARTITION RS VALUES('A') TABLESPACE TABLE_SPACE_DATA_2,
PARTITION RM VALUES('B') TABLESPACE TABLE_SPACE_DATA_3,
PARTITION RN VALUES('C') TABLESPACE TABLE_SPACE_DATA_4,
);

5) Reference Partition
- Reference Key๋กœ ์ง€์ •๋œ ๊ฒฝ์šฐ ๋ถ€๋ชจ ํ…Œ์ด๋ธ”์˜ ์ปฌ๋Ÿผ์ด ์กด์žฌํ•˜์ง€ ์•Š์•„๋„ ๋ถ€๋ชจ์˜ Partition Key๋กœ
๋ถ„ํ• ํ•˜๋Š” ๋ฐฉ์‹.
- ๊ตฌ๋ฌธ Sample
CREATE TABLE CUSTOMERS
(
CUST_ID NUMBER PRIMARY KEY,
CUST_NAME VARCHAR2(200),
RATING VARCHAR2(1) NOT NULL
)
PARTITION BY LIST(RATING)
(
PARTITION PA VALUES('A'),
PARTITION PB VALUES('B')
);

-- Detail Table
CREATE TABLE SALES
(
SALES_ID NUMBER PRIMARY KEY,
CUST_ID NUMBER NOT NULL,
SALES_AMT NUMBER,
CONSTRAINT FK_SALES_01 FOREIGN KEY (CUST_ID) REFERENCES CUSTOMERS
)
PARTITION BY REFERENCE (FK_SALES_01);
- ์ œ์•ฝ์กฐ๊ฑด
-> Foreign Key ์ œ์•ฝ์กฐ๊ฑด์ด ์„ค์ •๋˜์–ด ์žˆ์–ด์•ผ ํ•œ๋‹ค.
-> ์ƒ์†๋ฐ›๋Š” ํ…Œ์ด๋ธ”์˜ Key๊ฐ’์ด NOT NULL ์ด์–ด์•ผ ํ•œ๋‹ค.
- ํ…Œ์ŠคํŠธ
-- Normal
SELECT *
FROM SALE_TMP A,
CUSTOMERS B
WHERE A.CUST_ID = B.CUST_ID
AND B.RATING = 'A';

Rows Row Source Operation
------- ------------------------------------
0 STATEMENT
28 HASH JOIN
28 PARTITION LIST SINGLE PARTITION: 1
28 TABLE ACCESS FULL CUSTOMERS PARTITION: 1
56 TABLE ACCESS FULL SALE_TMP

-- Reference Partition
SELECT *
FROM SALES A,
CUSTOMERS B
WHERE A.CUST_ID = B.CUST_ID
AND B.RATING = 'A';

Rows Row Source Operation
------- -------------------------------------
0 STATEMENT
28 PARTITION LIST SINGLE PARTITION: 1
28 HASH JOIN
28 TABLE ACCESS FULL CUSTOMERS PARTITION: 1
28 TABLE ACCESS FULL SALES PARTITION: 1

6) Interval Partition
- Range Partition์—์„œ ํŠน์ • ๋ฒ”์œ„๋ฅผ ์ง€์ •ํ•˜๊ณ  ๊ด€๋ฆฌํ• ๋•Œ๋Š” ๋ฏธ๋ฆฌ Range๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์–ด์•ผ ํ•˜๊ณ 
์ƒ์„ฑ ์ดํ›„ ๋ถ„ํ•  ๋˜๋Š” ๋ณ‘ํ•ฉ์„ ํ•  ๋•Œ๋Š” ์ถ”๊ฐ€์ ์ธ ์ž‘์—…์„ ํ•ด์ฃผ์–ด์•ผ ํ•œ๋‹ค.
- ํ•˜์ง€๋งŒ 'Interval Partition'์—์„œ๋Š” ๊ฐ ํŒŒํ‹ฐ์…˜์„ ๋ฏธ๋ฆฌ ์ •์˜ํ•จ์œผ๋กœ์จ ํŒŒํ‹ฐ์…˜ ์ƒ์„ฑ์„ ์˜ค๋ผํด์ด
์ง์—… ํ•ด์ฃผ๋Š” ๋ฐฉ์‹์ด๋‹ค.
- ์˜ˆ์ œ Sample
-- 1. Range Partition ์ƒ์„ฑ
CREATE TABLE SALES6
(
SALES_ID NUMBER,
SALES_DT DATE
)
PARTITION BY RANGE(SALES_DT)
(
PARTITION P0701 VALUES LESS THAN (TO_DATE('20070201', 'YYYYMMDD')),
PARTITION P0701 VALUES LESS THAN (TO_DATE('20070301', 'YYYYMMDD'))
);

-- 2. Partition Key ๊ฐ’์˜ ๋ฒ”์œ„์— ์—†๋Š” ๊ฐ’์œผ๋กœ Insert
INSERT INTO SALES6 VALUES(1, TO_DATE('20070401', 'YYYYMMDD'));

-- Error
ORA-14400: inserted partition key does not map to any PARTITION

-- 3. Interval Partition ์ƒ์„ฑ
CREATE TABLE SALES6
(
SALES_ID NUMBER,
SALES_DT DATE
)
PARTITION BY RANGE(SALES_DT) INTERVAL (NUMTOYMINTERVAL(1, 'MONTH'))
(
PARTITION P0701 VALUES LESS THAN(TO_DATE('20080201', 'YYYYMMDD'))
);

-- 4. Partition Key ๊ฐ’์˜ ๋ฒ”์œ„์— ์—†๋Š” ๊ฐ’์œผ๋กœ Insert
INSERT INTO SALES6 VALUES(1, TO_DATE('20070601', 'YYYYMMDD'));

-- No Error
1 row created.

- ํŒŒํ‹ฐ์…˜์„ ํŠน์ • ํ…Œ์ด๋ธ” ์ŠคํŽ˜์ด์Šค์— ์ €์žฅํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด STORE IN ๊ตฌ๋ฌธ์œผ๋กœ ๊ฐ€๋Šฅํ•˜๋‹ค.
-> INTERVAL (NUMTOYMINTERVAL(1, 'MONTH')) STORE IN (TS1, TS2, TS3)
- ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ฐœ๋ฐœ์ž๊ฐ€ ํŠน์ • ํŒŒํ‹ฐ์…˜์— ์ ‘๊ทผํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด ๋‹ค์Œ์˜ ๊ตฌ๋ฌธ์œผ๋กœ ๊ฐ€๋Šฅํ•˜๋‹ค.
-> SELECT * FROM SALES6 PARTITION FOR(TO_DATE('20080501', 'YYYYMMDD'));

7) System Partition
- ํ…Œ์ด๋ธ” ์ƒ์„ฑ์‹œ ํŒŒํ‹ฐ์…˜ ๊ตฌ๊ฐ„์„ ๋ฏธ๋ฆฌ ์„ค์ •ํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ ์ž„์˜๋กœ ๋‚˜๋ˆˆ ํŒŒํ‹ฐ์…˜์— ๋Œ€ํ•ด
์‚ฌ์šฉ์ž๊ฐ€ ์›ํ•˜๋Š” ํŒŒํ‹ฐ์…˜์— ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•˜๋Š” ๋ฐฉ์‹.
- ์ด ๋ฐฉ์‹์€ ์‚ฌ์šฉ์ž๊ฐ€ 'System Partition'์œผ๋กœ ๋˜์–ด ์žˆ๋Š” ํ…Œ์ด๋ธ”์˜ ๋ฐ์ดํ„ฐ๋ฅผ DML ํ•˜๊ณ ์ž ํ•  ๋•Œ
์ง์ ‘ ํŒŒํ‹ฐ์…˜์„ ์ง€์ •ํ•˜์—ฌ ํ•ด์ฃผ์–ด์•ผ ํ•œ๋‹ค.
- ๋กœ์ปฌ ์ธ๋ฑ์Šค ์ƒ์„ฑ ์‹œ, ์ธ๋ฑ์Šค๋„ ๋™์ผํ•œ ๋ฐฉ๋ฒ•์œผ๋กœ ํŒŒํ‹ฐ์…”๋‹๋œ๋‹ค.
- ์˜ˆ์ œ Sample
CREATE TABLE SALES3
(
SALES_ID NUMBER,
PRODUCT_CODE NUMBER,
STATE_CODE NUMBER
)
PARTITION BY SYSTEM
(
PARTITION P1 TABLESPACE USERS,
PARTITION P2 TABLESPACE USERS
);
- Insert ํ•  ๋•Œ๋Š” ๋ฐ˜๋“œ์‹œ ํŒŒํ‹ฐ์…˜์„ ์ง€์ •ํ•ด ์ฃผ์–ด์•ผ ํ•œ๋‹ค.
-- Insert ํ•  ๋•Œ ํ…Œ์ด๋ธ”์˜ ํŒŒํ‹ฐ์…˜์„ ์ง€์ •ํ•˜์ง€ ์•Š์„ ๊ฒฝ์šฐ
INSERT INTO SALES3 VALUES(1,101,1);

-- Error
ERROR at line 1:
ORA-14701: partition-extended name or bind variable must be used for DMLs on
tables partitioned by the System method

-- Insert์„ ํ•  ๋•Œ ํ…Œ์ด๋ธ”์˜ ํŒŒํ‹ฐ์…˜์„ ์ง€์ •ํ•œ ๊ฒฝ์šฐ
insert into sales3 partition (p1) values (1,101,1);

-- No Error
1 row created.
- Delete, Update ํ•  ๋•Œ๋Š” ํ•„์ˆ˜๋Š” ์•„๋‹ˆ์ง€๋งŒ ํŒŒํ‹ฐ์…˜์„ ์ง€์ •ํ•˜์ง€ ์•Š์„ ๊ฒฝ์šฐ ๋ชจ๋“  ํŒŒํ‹ฐ์…˜์„
์ฐพ์•„๋‹ค๋…€์•ผ ํ•˜๋ฏ€๋กœ ์ด ๊ฒฝ์šฐ์—๋„ ๊ฐ€๊ธ‰์  ํŒŒํ‹ฐ์…˜์„ ์ง€์ •ํ•ด ์ฃผ์–ด์•ผ ํ•œ๋‹ค.
-> DELETE SALES3 PARTITION(P1) WHERE STATUS_CODE = 1;

8) Virtual Column Partition
- ํŒŒํ‹ฐ์…˜์œผ๋กœ ๋‚˜๋ˆ„๊ณ ์ž ํ•˜๋Š” ์ปฌ๋Ÿผ์ด ํ…Œ์ด๋ธ”์—์„œ ๊ฐ€๊ณต๋˜์–ด ์–ป์„ ์ˆ˜ ์žˆ๋Š” ์ปฌ๋Ÿผ์ผ ๊ฒฝ์šฐ
11g ์ด์ „์—์„œ๋Š” ์ƒˆ๋กœ์šด ์ปฌ๋Ÿผ์„ ์ถ”๊ฐ€ํ•˜๊ณ  ํŠธ๋ฆฌ๊ฑฐ๋ฅผ ์ด์šฉํ•˜์—ฌ ์ปฌ๋Ÿผ ๊ฐ’์„ ์ƒ์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์„
์‚ฌ์šฉํ•˜์—ฌ ๋งŽ์€ ์˜ค๋ฒ„ํ—ค๋“œ๋ฅผ ๊ฐ์ˆ˜ํ•˜์˜€์œผ๋‚˜, 11g์—์„œ๋Š” 'Virtual Column Partition'์„
์ง€์›ํ•˜์—ฌ ์‹ค์ œ๋กœ ์ €์žฅ๋˜์ง€ ์•Š๋Š” ์ปฌ๋Ÿผ์„ ๋Ÿฐํƒ€์ž„์— ๊ณ„์‚ฐํ•˜์—ฌ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ๋‹ค. ๋˜ํ•œ
๊ฐ€์ƒ ์ปฌ๋Ÿผ์— ํŒŒํ‹ฐ์…˜์„ ์ ์šฉํ•˜๋Š” ๊ฒƒ๋„ ๊ฐ€๋Šฅํ•˜๋‹ค.
- ์˜ˆ์ œ Sample
-- Virtual Partition ์ƒ์„ฑ
CREATE TABLE SALES
(
SALES_ID NUMBER,
CUST_ID NUMBER,
SALE_CATEGORY VARCHAR2(6)
GENERATED ALWAYS AS
(
CASE WHEN SALES_AMT <= 10000 THEN 'LOW'
WHEN SALES_AMT BETWEEN 10000 AND 100000 THEN CASE WHEN CUST_ID < 101 THEN 'LOW'
WHEN BETWEEN 101 AND 200 THEN 'MEDIUM'
ELSE 'LOW' END
WHEN SALES_AMT BETWEEN 100000 AND 1000000 THEN CASE WHEN CUST_ID < 101 THEN 'MEDIUM'
WHEN BETWEEN 101 AND 200 THEN 'HIGH'
ELSE 'ULTRA' END
ELSE 'ULTRA' END
) VIRTUAL
)
PARTITION BY LIST(SALES_CATEGORY)
(
PARTITION P_LOW VALUES ('LOW'),
PARTITION P_MEDIUM VALUES ('MEDIUM'),
PARTITION P_HIGH VALUES ('HIGH'),
PARTITION P_ULTRA VALUES ('ULTRA')
);

-- Insert ํ…Œ์ŠคํŠธ
INSERT INTO SALES(SALES_ID, CUST_ID, SALES_AMT) VALUES(1, 1, 100);

-- No Error
1 row created.

3. Partition Index
1) Local Index
- ์ธ๋ฑ์Šค๋ฅผ ์ƒ์„ฑํ•œ ์ธ๋ฑ์Šค์™€ ํŒŒํ‹ฐ์…˜๋œ ์ธ๋ฑ์Šค๊ฐ€ ๋™์ผํ•˜๊ฒŒ ํŒŒํ‹ฐ์…˜๋œ ํ˜•ํƒœ๋ฅผ ๋งํ•œ๋‹ค.
- ์ธ๋ฑ์Šค์™€ ํ…Œ์ด๋ธ”์€ ๊ฐ™์€ ์นผ๋Ÿผ์— ์˜ํ•ด ํŒŒํ‹ฐ์…˜๋˜๋ฉฐ, ํ•˜๋‚˜์˜ ์ธ๋ฑ์Šค ํŒŒํ‹ฐ์…˜์ด ํ…Œ์ด๋ธ”
ํŒŒํ‹ฐ์…˜ ํ•˜๋‚˜์™€ ๋Œ€์‘๋˜๋ฉฐ, ๋Œ€์‘๋˜๋Š” ์ธ๋ฑ์Šค ํŒŒํ‹ฐ์…˜๊ณผ ํ…Œ์ด๋ธ” ํŒŒํ‹ฐ์…˜์€ ๊ฐ๊ฐ ๊ฐ™์€ ๋ฒ”์œ„๋ฅผ ๊ฐ–๊ฒŒ ๋œ๋‹ค.
- ๊ฒฐ๊ตญ ํŠน์ •ํ•œ ํ•˜๋‚˜์˜ ์ธ๋ฑ์Šค์— ํฌํ•จ๋œ ๋ชจ๋“  Key๋“ค์€ ํ•˜๋‚˜์˜ ํ…Œ์ด๋ธ” ํŒŒํ‹ฐ์…˜ ๋‚ด์˜ ๋ฐ์ดํƒ€๋งŒ์„ ๊ฐ€๋ฆฌํ‚ค๊ฒŒ ๋œ๋‹ค.

1-1) Local Prefixed Index
- ์ธ๋ฑ์Šค์˜ ๋งจ ์•ž์— ์žˆ๋Š” ์ปฌ๋Ÿผ์— ์˜ํ•ด ํŒŒํ‹ฐ์…˜๋˜๋Š” ๋ฐฉ์‹์ด๋‹ค.
- Local Prefixed Index์—์„œ ์ปฌ๋Ÿผ์€ Unique/Non-Unique๋ฅผ ๋ชจ๋‘ ํ—ˆ์šฉํ•œ๋‹ค.
- Base Table์˜ ํŒŒํ‹ฐ์…˜์ด ๋ณ€๊ฒฝ๋˜๋ฉด Local Index์˜ ๊ด€๋ จ ํŒŒํ‹ฐ์…˜๋งŒ ๋ณ€๊ฒฝ์ด ๋œ๋‹ค.
CREATE TABLE DEPT
(
DEPTNO NUMBER NOT NULL,
DNAME VARCHAR2(10) NOT NULL,
LOC VARCHAR2(14)
)
PARTITION BY RANGE (DEPTNO)
(PARTITION PART_1 VALUES LESS THAN (30),
PARTITION PART_2 VALUES LESS THAN (MAXVALUE)
);

CREATE INDEX DEPT_N1 ON DEPT(DEPTNO) LOCAL;

1-2) Local Non-Prefixed Index
- Index์˜ ์ฒซ๋ฒˆ์งธ column์ด Partition Key๊ฐ€ ์•„๋‹Œ ํ˜•ํƒœ๋กœ Base Table๊ณผ ๋™์ผํ•œ Partition๊ตฌ์กฐ๋ฅผ ๊ฐ€์ง„ Index์ด๋‹ค.
(equi-partitioned)
- ๋น ๋ฅธ access๊ฐ€ ์š”๊ตฌ๋  ๋•Œ ์œ ์šฉํ•˜๋‹ค(Base Table์˜ Partition Key ๋Š” ์ œ์™ธ...)
- Partition๋‹จ์œ„๋กœ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ Global Index์— ๋น„ํ•ด ์šด์˜์ƒ ํŽธ๋ฆฌํ•˜๋‹ค.
- OLAP ์ธก๋ฉด์—์„œ Global Index๋ณด๋‹ค ์กฐํšŒ ์†๋„๊ฐ€ ์ €ํ•˜๋œ๋‹ค.
CREATE TABLE DEPT
(
DEPTNO NUMBER NOT NULL,
DNAME VARCHAR2(10) NOT NULL,
LOC VARCHAR2(14)
)
PARTITION BY RANGE (DEPTNO)
(PARTITION PART_1 VALUES LESS THAN (30),
PARTITION PART_2 VALUES LESS THAN (MAXVALUE)
);

CREATE INDEX DEPT_N2 ON DEPT(LOC) LOCAL;

2) Global Index
- Global Index๋Š” ํ…Œ์ด๋ธ”๊ณผ ๋‹ค๋ฅด๊ฒŒ ํŒŒํ‹ฐ์…˜๋˜๋Š” ๊ฒฝ์šฐ์ด๋‹ค.

2-1) Global Prefixed Index
- Base Table๊ณผ ๋น„๊ตํ•˜์—ฌ not equi-partitioned ์ƒํƒœ์ด๋‹ค.
- Oracle์€ only Index structure๋งŒ ๊ด€๋ฆฌํ•œ๋‹ค (Partition์€ ๊ด€๋ฆฌ์•ˆํ•จ)
- ์ตœ์ข… Partition์—๋Š” Maxvalue๊ฐ’์ด ๋ฐ˜๋“œ์‹œ ๊ธฐ์ˆ ๋˜์–ด์•ผ ํ•œ๋‹ค.
- Local index๋ณด๋‹ค ๊ด€๋ฆฌํ•˜๊ธฐ ํž˜๋“ค๋‹ค.
- ๊ธฐ์ค€ Table์˜ Partition์ด ๋ณ€๊ฒฝ๋˜๋ฉด global index์˜ ๋ชจ๋“  Partition์— ์˜ํ–ฅ์„ ๋ฏธ์นœ๋‹ค
(Global Index ์žฌ์ƒ์„ฑ ํ•ด์•ผ ํ•จ) -- ํ…Œ์ด๋ธ” ์ƒ์„ฑ
CREATE TABLE SALES_DATA_2008
(
COLUMN_1 NUMBER NOT NULL,
COLUMN_2 VARCHAR2(4),
COLUMN_3 VARCHAR2(4),
COLUMN_4 VARCHAR2(2),
COLUMN_5 VARCHAR2(2),
COLUMN_6 NUMBER
)
PARTITION BY RANGE ( COLUMN_3, COLUMN_4 )
(
PARTITION P_200801 VALUES LESS THAN ( '04', '01' ),
PARTITION P_200802 VALUES LESS THAN ( '07', '01' ),
PARTITION P_200803 VALUES LESS THAN ( '10', '01' ),
PARTITION P_200804 VALUES LESS THAN ( '12', MAXVALUE )
);

-- Global Prefixed Index
CREATE UNIQUE INDEX RANGE2_GPX8 ON SALES_DATA_2008( COLUMN_2, COLUMN_1)
TABLESPACE TABLE_SPACE_DATA_1
PCTFREE 10
STORAGE(INITIAL 100K NEXT 100K PCTINCREASE 0 )
GLOBAL PARTITION BY RANGE ( CODE )
(
PARTITION P_2008_P1 VALUES LESS THAN ('2000'),
PARTITION P_2008_P2 VALUES LESS THAN ('3000'),
PARTITION P_2008_P3 VALUES LESS THAN (MAXVALUE)
);


2-2) Non-Partitioned Index
- ํŒŒํ‹ฐ์…˜๊ณผ๋Š” ์•„๋ฌด๋Ÿฐ ์ƒ๊ด€์—†๋Š” Normal Index๋ฅผ ๋งํ•จ.


III. ํŒŒํ‹ฐ์…˜์„ ์‚ฌ์šฉํ•  ๋•Œ ์•Œ์•„์•ผ ํ•  ์‚ฌํ•ญ๋“ค

1. ํŒŒํ‹ฐ์…˜ ํ…Œ์ด๋ธ” ๋ฐ ์ธ๋ฑ์Šค ๊ด€๋ฆฌ๋ฅผ ์œ„ํ•œ ๋ช…๋ น์–ด๋“ค
1) ์ผ๋ฐ˜ ํ…Œ์ด๋ธ” ํŒŒํ‹ฐ์…˜ํ•˜๊ธฐ
- Export/Import! ํ•˜๋Š” ๋ฐฉ๋ฒ•
-- ํ…Œ์ด๋ธ”์„ Export ํ•œ๋‹ค.
exp user/password tables=number file=exp.dmp

-- ๋ฐฑ์—…๋ฐ›์€ ํ…Œ์ด๋ธ”์„ ์ œ๊ฑฐํ•œ๋‹ค.
drop table numbers;

-- ํŒŒํ‹ฐ์…˜ ํ…Œ์ด๋ธ”์„ ์ƒ์„ฑํ•œ๋‹ค.
CREATE TABLE NUMBER(QTY NUMBER(3), NAME VARCHAR2(15))
PARTITION BY RANGE(QTY)
(PARTITION P1 VALUES LESS THAN (501),
PARTITION P2 VALUES LESS THAN (MAXVALUE));

-- ignore=y๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฐ์ดํ„ฐ๋ฅผ Import!ํ•œ๋‹ค.
imp user/password tables=number file=exp.dmp ignore=y

- Subquery๋ฅผ ์ด์šฉํ•œ ๋ฐฉ๋ฒ•
-- ํŒŒํ‹ฐ์…˜ ํ…Œ์ด๋ธ”์„ ์ƒ์„ฑํ•œ๋‹ค.
CREATE TABLE PARTBL(QTY NUMBER(3), NAME VARCHAR2(15))
PARTITION BY RANGE(QTY)
(PARTITION P1 VALUES LESS THAN(501),
PARTITION P2 VALUES LESS THAN(MAXVALUE));

-- Subquery๋ฅผ ์ด์šฉํ•˜์—ฌ ํŒŒํ‹ฐ์…˜ ํ…Œ์ด๋ธ”์— ๋ฐ์ดํ„ฐ๋ฅผ ์ž…๋ ฅํ•œ๋‹ค.
INSERT INTO PARTBL(QTY, NAME) SELECT * FROM ORIGTBL;

-- Subquery๋ฅผ ์ด์šฉํ•˜์—ฌ ํŒŒํ‹ฐ์…˜ ํ…Œ์ด๋ธ”์— ๋ฐ์ดํ„ฐ๋ฅผ ์ž…๋ ฅํ•œ๋‹ค.

- Partition Exchange ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•
-- ALTER TABLE EXCHANGE PARTITION์€ ํŒŒํ‹ฐ์…˜ ํ…Œ์ด๋ธ”์„ ์ผ๋ฐ˜ ํ…Œ์ด๋ธ”๋กœ, ๋˜๋Š” ํŒŒํ‹ฐ์…˜๋˜์–ด
-- ์žˆ์ง€ ์•Š์€ ํ…Œ์ด๋ธ”์„ ํŒŒํ‹ฐ์…˜ ํ…Œ์ด๋ธ”๋กœ ๋ณ€๊ฒฝ์‹œํ‚ฌ ๋•Œ ์‚ฌ์šฉํ•œ๋‹ค.
-- ํŒŒํ‹ฐ์…˜ ํ…Œ์ด๋ธ” ์ƒ์„ฑ
CREATE TABLE P_EMP (SAL NUMBER(7,2))
PARTITION BY RANGE(SAL)
(PARTITION EMP_P1 VALUES LESS THAN (2000),
PARTITION EMP_P2 VALUES LESS THAN (4000));

-- ์ฒซ๋ฒˆ์งธ ํŒŒํ‹ฐ์…˜์— ๋“ค์–ด๊ฐˆ ๋ฐ์ดํ„ฐ
CREATE TABLE DUMMY_Y
SELECT SAL
FROM EMP
WHERE SAL < 2000;

-- ๋‘๋ฒˆ์งธ ํŒŒํ‹ฐ์…˜์— ๋“ค์–ด๊ฐˆ ๋ฐ์ดํ„ฐ
CREATE TABLE DUMMY_Z
SELECT SAL
FROM EMP
WHERE SAL BETWEEN 2000 AND 3999;

ALTER TABLE P_EMP EXCHANGE PARTITION EMP_P1
WITH TABLE DUMMY_Y;

ALTER TABLE P_EMP EXCHANGE PARTITION EMP_P2
WITH TABLE DUMMY_Z;

- ์—ฌ๋Ÿฌ ๊ฐœ์˜ ํŒŒํ‹ฐ์…˜์œผ๋กœ ๋ถ„๋ฆฌ๋œ ํ…Œ์ด๋ธ” ์ค‘ ์ผ๋ถ€์˜ ํŒŒํ‹ฐ์…˜๋งŒ ๊ฐ€์ง„ ํ…Œ์ด๋ธ” ์ƒ์„ฑํ•˜๊ธฐ
-- ๋ฐ์ดํƒ€๋ฅผ Exportํ•œ ํ›„ ํ•„์š”ํ•œ ํŒŒํ‹ฐ์…˜์œผ๋กœ ์ด๋ฃจ์–ด์ง„ ํ…Œ์ด๋ธ”์„ ์ƒ์„ฑํ•œ๋‹ค.
-- ๋ฐ์ดํ„ฐ ์ƒ์„ฑ
CREATE TABLE YEAR(COL1 DATE) PARTITION BY RANGE (COL1)
(PARTITION OCTOBER VALUES LESS THAN ('01-NOV-1999) TABLESPACE OCTOBER,
PARTITION NOVEMBER VALUES LESS THAN ('01-DEC-1999) TABLESPACE NOVEMBER,
PARTITION DECEMBER VALUES LESS THAN (MAXVALUE) TABLESPACE DECEMBER);

-- ๋ฐ์ดํƒ€๋ฅผ Import!
IMP USERNAME/PASSWORD FILE=EXPDAT.DMP FROMUSER=<OWNER> TOUSER=<OWNER>
TABLES=(YEAR:OCTOBER, YEAR:NOVEMBER, YEAR:DECEMBER)

- ํŒŒํ‹ฐ์…˜์„ ์ถ”๊ฐ€ํ•˜๋Š” ๋ฐฉ๋ฒ•
-- ํŒŒํ‹ฐ์…˜ ํ…Œ์ด๋ธ” ์ƒ์„ฑ
CREATE TABLE PART_TBL
(IN_DATE CHAR(8) PRIMARY KEY,
EMPNO NUMBER,
ENAME VARCHAR2(20),
JOB VARCHAR2(20))
PARTITION BY RANGE (IN_DATE)
(PARTITION PART_TBL_03 VALUE LESS THAN ('20000331') TABLESPACE PTS_03,
PARTITION PART_TBL_04 VALUE LESS THAN ('20000430') TABLESPACE PTS_04,
PARTITION PART_TBL_05 VALUE LESS THAN ('20000531') TABLESPACE PTS_05,
PARTITION PART_TBL_06 VALUE LESS THAN ('20000630') TABLESPACE PTS_06,
PARTITION PART_TBL_07 VALUE LESS THAN ('20000731') TABLESPACE PTS_07,
PARTITION PART_TBL_08 VALUE LESS THAN ('20000831') TABLESPACE PTS_08,
PARTITION PART_TBL_09 VALUE LESS THAN ('20000930') TABLESPACE PTS_09,
PARTITION PART_TBL_10 VALUE LESS THAN ('20001031') TABLESPACE PTS_10);

-- ํŒŒํ‹ฐ์…˜ ์ถ”๊ฐ€
ALTER TABLE PART_TBL ADD PARTITION PART_TBL_11 VALUES LESS THAN ('20001130') TABLESPACE PTS_11;
ALTER TABLE PART_TBL ADD PARTITION PART_TBL_12 VALUES LESS THAN ('20001231') TABLESPACE PTS_12;

- ํŠน์ • ํŒŒํ‹ฐ์…˜์„ ์‚ญ์ œํ•˜๋Š” ๋ฐฉ๋ฒ•
ํŠน์ • ํŒŒํ‹ฐ์…˜ ์‚ญ์ œ ์ดํ›„ ์‚ญ์ œํ•œ ํŒŒํ‹ฐ์…˜์˜ ๊ฐ’์ด ๋“ค์–ด์˜ฌ ๊ฒฝ์šฐ ๊ทธ ๋‹ค์Œ VALUES LESS THAN์œผ๋กœ ํŽธ์ž…๋œ๋‹ค.
ALTER TABLE PART_TBL DROP PARTITION PART_TBL_08;

- ํŒŒํ‹ฐ์…˜์„ ๋‚˜๋ˆ„๋Š” ๋ฐฉ๋ฒ•
๋งŒ์•ฝ 3์›”๋งŒ ๋“ค์–ด๊ฐ€์žˆ๋Š” ํŒŒํ‹ฐ์…˜์ด ์žˆ์„ ๊ฒฝ์šฐ, ์—ฌ๊ธฐ์„œ 1, 2์›”์„ ์ถ”๊ฐ€ํ•˜๋ ค๋ฉด ํŒŒํ‹ฐ์…˜์—์„œ Add๊ฐ€ ์•„๋‹Œ
Split์„ ํ•ด ์ฃผ์–ด์•ผ ํ•œ๋‹ค.
-- 3์›” ํŒŒํ‹ฐ์…˜์—์„œ 2์›”๊ณผ 3์›”์„ Splitํ•จ.
ALTER TABLE PART_TBL SPLIT PARTITION PART_TBL_03 AT ('20000229')
INTO (PARTITION PART_TBL_02 TABLESPACE PTS_02,
PARTITION PART_TBL_03_1 TABLESPACE PTS_03);

-- 2์›” ํŒŒํ‹ฐ์…˜์—์„œ 1์›”๊ณผ 2์›”์„ Splitํ•จ.
ALTER TABLE PART_TBL SPLIT PARTITION PART_TBL_02 AT ('20000131')
INTO (PARTITION PART_TBL_01 TABLESPACE PTS_01,
PARTITION PART_TBL_02_1 TABLESPACE PTS_02);

- ํŒŒํ‹ฐ์…˜ ์ด๋ฆ„์„ ๋ณ€๊ฒฝํ•˜๋Š” ๋ฐฉ๋ฒ•
ALTER TABLE PART_TBL RENAME PARTITION PART_TBL_02_1 TO PART_TBL_02;

- ํŒŒํ‹ฐ์…˜์˜ ํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค๋ฅผ ์˜ฎ๊ธฐ๋Š” ๋ฐฉ๋ฒ•
ALTER TABLE PART_TBL MOVE PARTITION PART_TBL_10 TABLESPACE PTS_10_1 NOLOGGING;

- ํŠน์ • ํŒŒํ‹ฐ์…˜์˜ ๋ฐ์ดํ„ฐ๋ฅผ Truncate ํ•˜๋Š” ๋ฐฉ๋ฒ•
Partition์˜ Data๋ฅผ ๋ชจ๋‘ ์‚ญ์ œํ•˜๋ ค๋ฉด Truncateํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์‚ฌ์šฉํ•  ์ˆ˜๊ฐ€ ์žˆ๋Š”๋ฐ,
Truncate๋Š” Rollback์ด ๋ถˆ๊ฐ€๋Šฅํ•˜๋ฉฐ ํŠน์ • Partition ์ „์ฒด๋ฅผ ์‚ญ์ œํ•˜๋ฏ€๋กœ ์ฃผ์˜ํ•˜์—ฌ ์‚ฌ์šฉํ•˜์—ฌ์•ผ ํ•œ๋‹ค.
ALTER TABLE PART_TBL TRUNCATE PARTITION PART_TBL_02;

- ํŒŒํ‹ฐ์…˜ ํ…Œ์ด๋ธ”์˜ ๋ฌผ๋ฆฌ์ ์ธ ์†์„ฑ ๋ณ€๊ฒฝํ•˜๋Š” ๋ฐฉ๋ฒ•
Partition Table์€ ํŠน์ • Partition์˜ ์†์„ฑ๋งŒ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ๊ณ ,
Table์˜ ์†์„ฑ์„ ๋ณ€๊ฒฝํ•˜์—ฌ ์ „์ฒด Partition์— ๋Œ€ํ•ด ๋™์ผํ•œ ๋ณ€๊ฒฝ์„ ํ•  ์ˆ˜ ์žˆ๋‹ค.

-- part_tbl์˜ ๋ชจ๋“  Partition์˜ Next ๊ฐ’์ด ๋ณ€๊ฒฝ
ALTER TABLE PART_TBL STORAGE (NEXT 10M);

part_tbl_05 Partition์˜ Maxextents ๊ฐ’๋งŒ ๋ณ€๊ฒฝ
ALTER TABLE PART_TBL MODIFY PARTITION PART_TBL_05 STORAGE (MAXEXTENTS 1000);

- ์ธ๋ฑ์Šค ๊ด€๋ฆฌ
ํŒŒํ‹ฐ์…˜ ํ…Œ์ด๋ธ” ๊ด€๋ จ ๋ณ€๊ฒฝ์ž‘์—…์„ ํ•œ ํ›„์—๋Š” ํ…Œ์ด๋ธ”์— ๊ฑธ๋ ค์žˆ๋Š” Local, Glocal Index์— ๋Œ€ํ•ด
๋ฐ˜๋“œ์‹œ Rebuild๋ฅผ ํ•ด ์ฃผ์–ด์•ผ ํ•œ๋‹ค. -- ํŠน์ • ํŒŒํ‹ฐ์…˜์˜ ์ธ๋ฑ์Šค Rebuild
ALTER INDEX IND_PART_TBL REBUILD PARTITION I_PART_TBL_02;

-- ๊ธ€๋กœ๋ฒŒ ์ธ๋ฑ์Šค Rebuild
ALTER INDEX PART_TBL_PK REBUILD;

2. Backup & Recovery
1) Export
- Table-Level Export
๊ธฐ์กด์˜ Table Export์ฒ˜๋Ÿผ Table ์ „์ฒด๋ฅผ Exportํ•˜๋Š” ๊ฒฝ์šฐ์ด๋‹ค.
์ด๋Š” Emp Table(Partitioned ๋˜๋Š” Non-Partitioned) ์ „์ฒด๋ฅผ Exportํ•˜๋Š” ๊ฒฝ์šฐ์ด๋‹ค.
$ exp scott/tiger tables=emp file=emp.dmp

- Partition-Level Export
์ด๋Š” Partition Table์˜ ์ผ๋ถ€ Partition๋งŒ์„ Exportํ•˜๋Š” ๊ฒƒ์œผ๋กœ,
Full Mode์˜ Export์‹œ์—๋Š” ์‚ฌ์šฉํ•˜์ง€ ๋ชปํ•˜๊ณ , Table๋‹จ์œ„์˜ Export์‹œ์—๋งŒ ๊ฐ€๋Šฅํ•˜๋‹ค.
':' ์„ ์ด์šฉํ•˜์—ฌ Partition ์ด๋ฆ„์„ ์ง€์ •ํ•˜๋ฉฐ ์ด ๊ฒฝ์šฐ Emp Table์˜ px Partition๋งŒ์„ Export
$ exp scott/tiger tables=emp:px file=emp_par.dmp

- ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋‘ ๊ฐ€์ง€ ๊ฒฝ์šฐ๋ฅผ Level์„ ํ˜ผ์šฉํ•˜์—ฌ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ๋„ ๊ฐ€๋Šฅํ•˜๋‹ค.
Sales Table์€ ์ „๋ถ€๋ฅผ, Emp Table์—์„œ๋Š” px Partition๋งŒ์„ Export.
$ exp scott/tiger tables=(emp:px, sales) file=both.dmp

2) Import!
- Table-Level Import!
Partitioned ๋˜๋Š” Non-Partitioned Table ์ „์ฒด๋ฅผ Import!ํ•œ๋‹ค.
๋ชจ๋“  Import! Mode (full, user, table)์—์„œ ์‚ฌ์šฉ๋œ๋‹ค.
emp table(Partitioned ๋˜๋Š” non-Partitioned) ์ „์ฒด๋ฅผ Import!
$ imp scott/tiger file=wookpark.dmp tables=emp

- Partition-Level Import!
Export Dump File์—์„œ (full, user, table์ค‘ ์–ด๋– ํ•œ Mode๋ฅผ ์ด์šฉํ•˜์—ฌ Exportํ–ˆ๊ฑด๊ฐ„์—)
Partitioned Tabled์˜ ์ผ๋ถ€ Partition๋งŒ์„ Import!ํ•œ๋‹ค.
Table Import! Mode์—์„œ๋งŒ ์‚ฌ์šฉ๊ฐ€๋Šฅํ•˜๋‹ค.


-- emp table์˜ px Partition๋งŒ์„ Import!.
-- ':'์„ ์ด์šฉํ•˜์—ฌ Partition์„ ์ง€์ •
$ imp scott/tiger file=wookpark.dmp tables=emp:px

ํ…Œ์ด๋ธ” ๋‹จ์œ„์˜ Import!์‹œ ์šฐ์„  Table Creation ๋ฌธ์žฅ์„ ์ˆ˜ํ–‰ํ•˜๊ณ  Row Insert๋ฌธ์„ ์ˆ˜ํ–‰ํ•˜๋Š” ๊ฒƒ๊ณผ
๋งˆ์ฐฌ๊ฐ€์ง€๋กœ, Partition-level Import!๋„ ์šฐ์„  Partitioned Table์˜ ์ƒ์„ฑ ๋ฌธ์žฅ์„ ์ˆ˜ํ–‰ํ•˜๊ณ 
Row Insert๋ฌธ์„ ์ˆ˜ํ–‰ํ•˜๊ฒŒ ๋œ๋‹ค.
๋”ฐ๋ผ์„œ ignore=y option๋“ฑ์„ ์ ์ ˆํžˆ ์‚ฌ์šฉํ•˜๋ฉด, Non-Partitioned Table๊ณผ Partitioned Table๊ฐ„์˜ ๋ณ€๊ฒฝ,
Partitioned Table์˜ ๊ตฌ์กฐ ๋ณ€๊ฒฝ๋“ฑ์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋œ๋‹ค.
๋‹ค์Œ์—๋Š” ๊ทธ ์ค‘ ๋ช‡ ๊ฐ€์ง€ ์˜ˆ์ด๋‹ค.

1. ํŒŒํ‹ฐ์…˜๋˜์–ด ์žˆ์ง€ ์•Š์€ ํ…Œ์ด๋ธ”์„ Exp, Imp๋ฅผ ์ด์šฉํ•˜์—ฌ ํŒŒํ‹ฐ์…˜ ํ•˜๋Š” ์˜ˆ

1) ํŒŒํ‹ฐ์…˜๋˜์–ด ์žˆ์ง€ ์•Š์€ ํ…Œ์ด๋ธ”์„ Exportํ•œ๋‹ค.
$ exp scott/tiger file=wookpark.dmp tables=emp

2) ํ•ด๋‹น Table์„ Dropํ•œ๋‹ค.
DROP TABLE EMP

3) ํŒŒํ‹ฐ์…˜ ํ…Œ์ด๋ธ”์„ ์ƒ์„ฑํ•œ๋‹ค.
CREATE TABLE EMP
(EMPNO NUMBER(4) NOT NULL,
....
)
PARTITION BY RANGE (EMPNO),
(PARTITION EMP1 VALUES LESS THAN (1000) TABLESPACE TS1,
PARTITION EMP1 VALUES LESS THAN (2000) TABLESPACE TS2,
PARTITION EMP1 VALUES LESS THAN (3000) TABLESPACE TS3);

4) Import!ํ•œ๋‹ค.
$ imp scott/tiger file=wookpark.dmp tables=emp ignore=y

2. Partitioned Table์˜ Partition๋“ค์„ exp/imp๋ฅผ ์ด์šฉํ•˜์—ฌ Mergeํ•˜๋Š” ์˜ˆ
1) Merge์˜ ๋Œ€์ƒ์ด ๋˜๋Š” Partition์„ Exportํ•œ๋‹ค.
$exp scott/tiger file=wookpark.dmp tables=emp:emp2

2) Merge์˜ ๋Œ€์ƒ์ด ๋˜๋Š” Partition์„ 'alter table...'๋ฌธ์žฅ์œผ๋กœ Dropํ•œ๋‹ค.
ALTER TABLE EMP DROP PARTITION EMP2;

3) Import!ํ•œ๋‹ค.
$imp scott/tiger file=wookpark.dmp tables=emp:emp3 ignore=y
์ดํ›„ emp Table์„ ํ™•์ธํ•˜๋ฉด, emp2 Partition์— ์žˆ๋˜ Data๊ฐ€ emp3 Partition์— Merge๋˜์–ด ์žˆ์Œ์„
ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

3. IU(Index Unusable) ๋ฐœ์ƒ ์ฃผ์˜
1) IU(Index Unusable)๋ž€ ํŒŒํ‹ฐ์…˜์ด ๋ณ€๊ฒฝ๋จ์œผ๋กœ ์ธํ•ด ํŒŒํ‹ฐ์…˜ ํ…Œ์ด๋ธ”์— ์žˆ๋Š” ์ธ๋ฑ์Šค์— ์˜ํ–ฅ์„ ์ฃผ์–ด
SELECT๋‚˜ DML์„ ์‹œ๋„ํ•  ๋•Œ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒ๋˜๋Š” ๊ฒƒ์„ ๋งํ•œ๋‹ค.

2) IU(Index Unusable)๋ฅผ ๋ฐœ์ƒ์‹œํ‚ค๋Š” Case
- Direct path Load์˜ ๊ฒฝ์šฐ
Direct path SQL*Loader ์ˆ˜ํ–‰ ํ›„ ์ธ๋ฑ์Šค๊ฐ€ ํ…Œ์ด๋ธ”์˜ ํ•ด๋‹น ๋ฐ์ดํ„ฐ๋ณด๋‹ค ์ด์ „ ๊ฒƒ์ด๋ฉด,
Unusable ์ƒํƒœ๊ฐ€ ๋œ๋‹ค (Oracle7์—์„œ๋Š” ์ธ๋ฑ์Šค๊ฐ€ Direct Load State๊ฐ€ ๋˜์—ˆ๋‹ค๊ณ  ํ‘œํ˜„ํ•œ๋‹ค).
์ธ๋ฑ์Šค๊ฐ€ ํ…Œ์ด๋ธ”์˜ ๋ฐ์ดํ„ฐ๋ณด๋‹ค ์ด์ „ ์ƒํƒœ๋ผ๋Š” ๊ฒƒ์€ ๋ฐ์ดํ„ฐ๋ฅผ Loadํ•œ ํ›„ ์ธ๋ฑ์Šค๋ฅผ ์ƒ์„ฑํ•˜๋Š” ์ค‘์—
Space ๋ถ€์กฑ ๋“ฑ์˜ ์›์ธ์œผ๋กœ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•˜์˜€๊ฑฐ๋‚˜, SKIP_INDEX_MAINTENANCE Option์„ ์‚ฌ์šฉํ•œ ๊ฒฝ์šฐ์ด๋‹ค.

- ROWID๊ฐ€ ๋ณ€๊ฒฝ๋˜๋Š” ๊ฒฝ์šฐ
ALTER TABLE MOVE PARTITION๊ณผ ๊ฐ™์ด ROWID๋ฅผ ๋ณ€ํ™”์‹œํ‚ค๋Š” ์ž‘์—…์€ ์˜ํ–ฅ๋ฐ›๋Š” Local Index์™€
์ „์ฒด Global Index๋ฅผ Unusable ์ƒํƒœ๊ฐ€ ๋˜๊ฒŒ ํ•œ๋‹ค.

- ROWID๋ฅผ ์ง€์šฐ๋Š” ์ž‘์—…
ALTER TABLE TRUNCATE PARTITION์ด๋‚˜ DROP PARTITION๊ณผ ๊ฐ™์ด ํ…Œ์ด๋ธ”์˜ Row๋ฅผ ์ง€์šฐ๋Š” ๊ฒฝ์šฐ
์˜ํ–ฅ๋ฐ›๋Š” Local Index Partition๊ณผ ๋ชจ๋“  Global Index Partition์„ Unusable ์ƒํƒœ๋กœ ๋งŒ๋“ ๋‹ค.

- ํ…Œ์ด๋ธ” Partition ์ •์˜๋ฅผ ๋ณ€๊ฒฝํ•˜๋Š” ๊ฒฝ์šฐ
ALTER TABLE SPLIT PARTITION์€ Local Index์˜ Partition Definition์€ ๋ณ€๊ฒฝ์‹œํ‚ค์ง€๋งŒ,
์ž๋™์œผ๋กœ ์ธ๋ฑ์Šค๋ฅผ ์ƒˆ๋กœ์šด Definition์— ๋งž๊ฒŒ Rebuildํ•˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— ์˜ํ–ฅ๋ฐ›๋Š”
Local Index Partition์„ Unusable ์ƒํƒœ๋กœ ๋งŒ๋“ ๋‹ค.
๋˜ํ•œ ์ด๊ฒƒ์€ ROWID๋ฅผ ๋ณ€๊ฒฝ์‹œํ‚ค๊ธฐ ๋•Œ๋ฌธ์— ๋ชจ๋“  Global Index Partition์„ Unusable ์ƒํƒœ๋กœ ๋งŒ๋“ ๋‹ค.

- ์ธ๋ฑ์Šค Partition ์ •์˜๋ฅผ ๋ณ€๊ฒฝํ•˜๋Š” ๊ฒฝ์šฐ
ALTER INDEX SPLIT PARTITION์€ Index์˜ Definition์€ ๋ณ€๊ฒฝ์‹œํ‚ค์ง€๋งŒ,
์˜ํ–ฅ๋ฐ›์€ Partition์€ Rebuild์‹œํ‚ค์ง€ ์•Š๋Š”๋‹ค.
์ด ์ž‘์—…์€ ์˜ํ–ฅ๋ฐ›๋Š” ์ธ๋ฑ์Šค ํŒŒํ‹ฐ์…˜ ๋ถ€๋ถ„์„ Unusable ์ƒํƒœ๋กœ ๋งŒ๋“ ๋‹ค.
๊ทธ๋Ÿฌ๋‚˜ Global Index์˜ ๊ฒฝ์šฐ๋Š” ๊ทธ๋Œ€๋กœ Usable ์ƒํƒœ๋กœ ๋œ๋‹ค.

3) ๊ฒฐ๊ณผ์ ์œผ๋กœ IU ์ƒํƒœ๊ฐ€ ๋˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์กฐ์น˜ํ•ด์•ผ ํ•œ๋‹ค.
- Partition Index : Rebuild
- Non-Partition Index : Drop and Recreate

IV. ์ผ๋ฐ˜ ํ…Œ์ด๋ธ”๊ณผ ํŒŒํ‹ฐ์…˜ ํ…Œ์ด๋ธ” ํ…Œ์ŠคํŠธ
0. ๊ธฐ์ดˆ ๋ฐ์ดํ„ฐ ๋งŒ๋“ค๊ธฐ
1) ์ผ๋ฐ˜ ํ…Œ์ด๋ธ”

โ‘  ํ…Œ์ด๋ธ”
CREATE TABLE APPS.NORMAL_TEST_TAB
(
MON_P1 DATE,
GRP_P2 NUMBER,
CNT_N1 NUMBER
);

โ‘ก ์ƒ˜ํ”Œ ๋ฐ์ดํ„ฐ ๋„ฃ๊ธฐ
INSERT INTO APPS.NORMAL_TEST_TAB
SELECT ADD_MONTHS(TO_DATE('200001', 'YYYYMM'),
DECODE(MOD(LEVEL, 10000),
0,
TRUNC(LEVEL / 10000),
TRUNC(LEVEL / 10000) + 1) - 1) MON_P1,
DECODE(MOD(LEVEL, 100),
0,
TRUNC(LEVEL / 100),
TRUNC(LEVEL / 100) + 1) * 100 GRP_P2,
LEVEL CNT_N1
FROM DUAL
CONNECT BY LEVEL <= 1000000
;

COMMIT;

โ‘ข ํ†ต๊ณ„์ •๋ณด
BEGIN
DBMS_STATS.GATHER_TABLE_STATS('APPS',
'NORMAL_TEST_TAB',
CASCADE => TRUE);
END;
/

NORMAL_TEST_TAB
---------------
Rows=997,141 Blocks=3,032
Empty Blocks=0 Avg Space=0
Chain Count=0 Avg Row Length=16
Avg Space Freelist Blocks=0 Freelist Blocks=0
Sample Size=54,167 Last Analyze=2008/08/24
Partitioned=NO

Column Name Nullable Column Type Distinct Buckets
-------------------------------- -------- ------------- ---------- ----------
MON_P1 DATE 101 1
GRP_P2 NUMBER 9,999 1
CNT_N1 NUMBER 997,141 1

INDEX
-----------------------------------------------------------------------------

2) ํŒŒํ‹ฐ์…˜ ํ…Œ์ด๋ธ”

โ‘  ํ…Œ์ด๋ธ”
CREATE TABLE APPS.PARTITION_TEST_TAB
(
MON_P1 DATE,
GRP_P2 NUMBER,
CNT_N1 NUMBER
)
PARTITION BY RANGE ( MON_P1 )
SUBPARTITION BY HASH( GRP_P2 )
(
PARTITION P200001 VALUES LESS THAN(TO_DATE('200001', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200002 VALUES LESS THAN(TO_DATE('200002', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200003 VALUES LESS THAN(TO_DATE('200003', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200004 VALUES LESS THAN(TO_DATE('200004', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200005 VALUES LESS THAN(TO_DATE('200005', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200006 VALUES LESS THAN(TO_DATE('200006', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200007 VALUES LESS THAN(TO_DATE('200007', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200008 VALUES LESS THAN(TO_DATE('200008', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200009 VALUES LESS THAN(TO_DATE('200009', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200010 VALUES LESS THAN(TO_DATE('200010', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200011 VALUES LESS THAN(TO_DATE('200011', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200012 VALUES LESS THAN(TO_DATE('200012', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200101 VALUES LESS THAN(TO_DATE('200101', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200102 VALUES LESS THAN(TO_DATE('200102', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200103 VALUES LESS THAN(TO_DATE('200103', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200104 VALUES LESS THAN(TO_DATE('200104', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200105 VALUES LESS THAN(TO_DATE('200105', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200106 VALUES LESS THAN(TO_DATE('200106', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200107 VALUES LESS THAN(TO_DATE('200107', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200108 VALUES LESS THAN(TO_DATE('200108', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200109 VALUES LESS THAN(TO_DATE('200109', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200110 VALUES LESS THAN(TO_DATE('200110', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200111 VALUES LESS THAN(TO_DATE('200111', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200112 VALUES LESS THAN(TO_DATE('200112', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200201 VALUES LESS THAN(TO_DATE('200201', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200202 VALUES LESS THAN(TO_DATE('200202', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200203 VALUES LESS THAN(TO_DATE('200203', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200204 VALUES LESS THAN(TO_DATE('200204', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200205 VALUES LESS THAN(TO_DATE('200205', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200206 VALUES LESS THAN(TO_DATE('200206', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200207 VALUES LESS THAN(TO_DATE('200207', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200208 VALUES LESS THAN(TO_DATE('200208', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200209 VALUES LESS THAN(TO_DATE('200209', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200210 VALUES LESS THAN(TO_DATE('200210', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200211 VALUES LESS THAN(TO_DATE('200211', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200212 VALUES LESS THAN(TO_DATE('200212', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200301 VALUES LESS THAN(TO_DATE('200301', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200302 VALUES LESS THAN(TO_DATE('200302', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200303 VALUES LESS THAN(TO_DATE('200303', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200304 VALUES LESS THAN(TO_DATE('200304', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200305 VALUES LESS THAN(TO_DATE('200305', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200306 VALUES LESS THAN(TO_DATE('200306', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200307 VALUES LESS THAN(TO_DATE('200307', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200308 VALUES LESS THAN(TO_DATE('200308', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200309 VALUES LESS THAN(TO_DATE('200309', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200310 VALUES LESS THAN(TO_DATE('200310', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200311 VALUES LESS THAN(TO_DATE('200311', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200312 VALUES LESS THAN(TO_DATE('200312', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200401 VALUES LESS THAN(TO_DATE('200401', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200402 VALUES LESS THAN(TO_DATE('200402', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200403 VALUES LESS THAN(TO_DATE('200403', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200404 VALUES LESS THAN(TO_DATE('200404', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200405 VALUES LESS THAN(TO_DATE('200405', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200406 VALUES LESS THAN(TO_DATE('200406', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200407 VALUES LESS THAN(TO_DATE('200407', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200408 VALUES LESS THAN(TO_DATE('200408', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200409 VALUES LESS THAN(TO_DATE('200409', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200410 VALUES LESS THAN(TO_DATE('200410', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200411 VALUES LESS THAN(TO_DATE('200411', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200412 VALUES LESS THAN(TO_DATE('200412', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200501 VALUES LESS THAN(TO_DATE('200501', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200502 VALUES LESS THAN(TO_DATE('200502', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200503 VALUES LESS THAN(TO_DATE('200503', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200504 VALUES LESS THAN(TO_DATE('200504', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200505 VALUES LESS THAN(TO_DATE('200505', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200506 VALUES LESS THAN(TO_DATE('200506', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200507 VALUES LESS THAN(TO_DATE('200507', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200508 VALUES LESS THAN(TO_DATE('200508', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200509 VALUES LESS THAN(TO_DATE('200509', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200510 VALUES LESS THAN(TO_DATE('200510', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200511 VALUES LESS THAN(TO_DATE('200511', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200512 VALUES LESS THAN(TO_DATE('200512', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200601 VALUES LESS THAN(TO_DATE('200601', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200602 VALUES LESS THAN(TO_DATE('200602', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200603 VALUES LESS THAN(TO_DATE('200603', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200604 VALUES LESS THAN(TO_DATE('200604', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200605 VALUES LESS THAN(TO_DATE('200605', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200606 VALUES LESS THAN(TO_DATE('200606', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200607 VALUES LESS THAN(TO_DATE('200607', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200608 VALUES LESS THAN(TO_DATE('200608', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200609 VALUES LESS THAN(TO_DATE('200609', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200610 VALUES LESS THAN(TO_DATE('200610', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200611 VALUES LESS THAN(TO_DATE('200611', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200612 VALUES LESS THAN(TO_DATE('200612', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200701 VALUES LESS THAN(TO_DATE('200701', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200702 VALUES LESS THAN(TO_DATE('200702', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200703 VALUES LESS THAN(TO_DATE('200703', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200704 VALUES LESS THAN(TO_DATE('200704', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200705 VALUES LESS THAN(TO_DATE('200705', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200706 VALUES LESS THAN(TO_DATE('200706', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200707 VALUES LESS THAN(TO_DATE('200707', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200708 VALUES LESS THAN(TO_DATE('200708', 'YYYYMM')) SUBPARTITIONS 100,
PARTITION P200709 VALUES LESS THAN(TO_DATE('200709', 'YYYYMM')) SUBPARTITIONS 100,
-- 9400์—์„œ 10,000๊ฐœ ํŒŒํ‹ฐ์…˜์— ๊ทผ์ ‘ํ•ด์„œ ๋” ๋Š˜์–ด๋‚˜๋Š” ๊ตฌ๊ฐ„์ด๋ผ MAXVALUE ์ฒ˜๋ฆฌํ•จ
PARTITION P5 VALUES LESS THAN(MAXVALUE) SUBPARTITIONS 100
);

โ‘ก ์ƒ˜ํ”Œ ๋ฐ์ดํ„ฐ ๋„ฃ๊ธฐ
INSERT INTO APPS.PARTITION_TEST_TAB
SELECT ADD_MONTHS(TO_DATE('200001', 'YYYYMM'),
DECODE(MOD(LEVEL, 10000),
0,
TRUNC(LEVEL / 10000),
TRUNC(LEVEL / 10000) + 1) - 1) MON_P1,
DECODE(MOD(LEVEL, 100),
0,
TRUNC(LEVEL / 100),
TRUNC(LEVEL / 100) + 1) * 100 GRP_P2,
LEVEL CNT_N1
FROM DUAL
CONNECT BY LEVEL <= 1000000
;

COMMIT;

โ‘ข ํ†ต๊ณ„์ •๋ณด
BEGIN
DBMS_STATS.GATHER_TABLE_STATS('APPS',
'PARTITION_TEST_TAB',
CASCADE => TRUE);
END;
/

PARTITION_TEST_TAB
------------------
Rows=998,668 Blocks=74,646
Empty Blocks=0 Avg Space=0
Chain Count=0 Avg Row Length=16
Avg Space Freelist Blocks=0 Freelist Blocks=0
Sample Size=56,777 Last Analyze=2008/08/24
Partitioned=YES

Column Name Nullable Column Type Distinct Buckets
-------------------------------- -------- ------------- ---------- ----------
MON_P1 DATE 101 1
GRP_P2 NUMBER 9,994 1
CNT_N1 NUMBER 998,668 1

INDEX
-----------------------------------------------------------------------------


1. Full Table Scan
1) ํŒŒํ‹ฐ์…˜ ํ‚ค๋กœ Full Table Scan

โ‘  ์ผ๋ฐ˜ ํ…Œ์ด๋ธ”
SELECT *
FROM NORMAL_TEST_TAB
WHERE MON_P1 = :B1 -- 2007/01/01
AND GRP_P2 = :B2 -- 841000
;

Call Count CPU Time Elapsed Time Disk Query Current Rows
------- ------ -------- ------------ ---------- ---------- ---------- ----------
Parse 1 0.000 0.000 0 0 0 0
Execute 1 0.000 0.000 0 0 0 0
Fetch 11 0.080 0.087 0 3064 0 100
------- ------ -------- ------------ ---------- ---------- ---------- ----------
Total 13 0.080 0.088 0 3064 0 100

Misses in library cache during parse: 0
Optimizer goal: ALL_ROWS
Parsing user: APPS (ID=44)

Rows Row Source Operation
------- ---------------------------------------------------
0 STATEMENT
100 TABLE ACCESS FULL NORMAL_TEST_TAB (cr=3064 pr=0 pw=0 time=70247 us)

โ‘ก ํŒŒํ‹ฐ์…˜ ํ…Œ์ด๋ธ”
SELECT *
FROM PARTITION_TEST_TAB
WHERE MON_P1 = :B1 -- 2007/01/01
AND GRP_P2 = :B2 -- 841000
;

Call Count CPU Time Elapsed Time Disk Query Current Rows
------- ------ -------- ------------ ---------- ---------- ---------- ----------
Parse 1 0.000 0.000 0 0 0 0
Execute 1 0.000 0.000 0 0 0 0
Fetch 11 0.000 0.001 0 25 0 100
------- ------ -------- ------------ ---------- ---------- ---------- ----------
Total 13 0.000 0.001 0 25 0 100

Misses in library cache during parse: 0
Optimizer goal: ALL_ROWS
Parsing user: APPS (ID=44)

Rows Row Source Operation
------- ---------------------------------------------------
0 STATEMENT
100 PARTITION RANGE SINGLE PARTITION: KEY KEY (cr=25 pr=0 pw=0 time=120 us)
100 PARTITION HASH SINGLE PARTITION: KEY KEY (cr=25 pr=0 pw=0 time=96 us)
100 TABLE ACCESS FULL PARTITION_TEST_TAB PARTITION: KEY KEY (cr=25 pr=0 pw=0 time=80 us)


2) ํŒŒํ‹ฐ์…˜ ํ‚ค๊ฐ€ ์•„๋‹Œ ๊ฒƒ์œผ๋กœ Full Table Scan

โ‘  ์ผ๋ฐ˜ ํ…Œ์ด๋ธ”
SELECT *
FROM NORMAL_TEST_TAB
WHERE CNT_N1 = :B1 -- 900000
;

Call Count CPU Time Elapsed Time Disk Query Current Rows
------- ------ -------- ------------ ---------- ---------- ---------- ----------
Parse 1 0.000 0.000 0 0 0 0
Execute 1 0.000 0.000 0 0 0 0
Fetch 2 0.400 0.412 0 3055 0 1
------- ------ -------- ------------ ---------- ---------- ---------- ----------
Total 4 0.400 0.412 0 3055 0 1

Misses in library cache during parse: 0
Optimizer goal: ALL_ROWS
Parsing user: APPS (ID=44)

Rows Row Source Operation
------- ---------------------------------------------------
0 STATEMENT
1 TABLE ACCESS FULL NORMAL_TEST_TAB (cr=3055 pr=0 pw=0 time=371933 us)

โ‘ก ํŒŒํ‹ฐ์…˜ ํ…Œ์ด๋ธ”
-- 2๊ฐœ ํŒŒํ‹ฐ์…˜ ํ‚ค ๋ชจ๋‘ ์—†์ด
SELECT *
FROM PARTITION_TEST_TAB
WHERE CNT_N1 = :B1 -- 900000
;

Call Count CPU Time Elapsed Time Disk Query Current Rows
------- ------ -------- ------------ ---------- ---------- ---------- ----------
Parse 1 0.000 0.000 0 0 0 0
Execute 1 0.000 0.000 0 0 0 0
Fetch 2 0.940 0.936 0 97104 0 1
------- ------ -------- ------------ ---------- ---------- ---------- ----------
Total 4 0.940 0.937 0 97104 0 1

Misses in library cache during parse: 0
Optimizer goal: ALL_ROWS
Parsing user: APPS (ID=44)

Rows Row Source Operation
------- ---------------------------------------------------
0 STATEMENT
1 PARTITION RANGE ALL PARTITION: 1 94 (cr=97104 pr=0 pw=0 time=873415 us)
1 PARTITION HASH ALL PARTITION: 1 100 (cr=97104 pr=0 pw=0 time=933492 us)
1 TABLE ACCESS FULL PARTITION_TEST_TAB PARTITION: 1 9400 (cr=97104 pr=0 pw=0 time=924367 us)

-- 1๊ฐœ ํŒŒํ‹ฐ์…˜ ํ‚ค ์„ ๋‘(1๋ธ”๋Ÿญ๋‹น 5๊ฐœ ๋กœ์šฐ ์•ก์„ธ์Šค - ๊ทธ๋‚˜๋งˆ ํšจ์œจ)
SELECT *
FROM PARTITION_TEST_TAB
WHERE MON_P1 = :B1 -- 2007/01/01
;

Call Count CPU Time Elapsed Time Disk Query Current Rows
------- ------ -------- ------------ ---------- ---------- ---------- ----------
Parse 1 0.000 0.000 0 0 0 0
Execute 1 0.000 0.000 0 0 0 0
Fetch 1001 0.000 0.046 0 1948 0 10000
------- ------ -------- ------------ ---------- ---------- ---------- ----------
Total 1003 0.000 0.046 0 1948 0 10000

Misses in library cache during parse: 0
Optimizer goal: ALL_ROWS
Parsing user: APPS (ID=44)

Rows Row Source Operation
------- ---------------------------------------------------
0 STATEMENT
10000 PARTITION RANGE SINGLE PARTITION: KEY KEY (cr=1948 pr=0 pw=0 time=40165 us)
10000 PARTITION HASH ALL PARTITION: 1 100 (cr=1948 pr=0 pw=0 time=40148 us)
10000 TABLE ACCESS FULL PARTITION_TEST_TAB PARTITION: KEY KEY (cr=1948 pr=0 pw=0 time=3704 us)

-- 1๊ฐœ ํŒŒํ‹ฐ์…˜ ํ‚ค ํ›„๋ฐœ(100๋ธ”๋Ÿญ๋‹น 8๊ฐœ ๋กœ์šฐ ์•ก์„ธ์Šค - ๋น„ํšจ์œจ์ )
SELECT *
FROM PARTITION_TEST_TAB
WHERE GRP_P2 = :B2 -- 841000
;

Call Count CPU Time Elapsed Time Disk Query Current Rows
------- ------ -------- ------------ ---------- ---------- ---------- ----------
Parse 1 0.000 0.000 0 0 0 0
Execute 1 0.000 0.000 0 0 0 0
Fetch 11 0.010 0.013 0 1240 0 100
------- ------ -------- ------------ ---------- ---------- ---------- ----------
Total 13 0.010 0.013 0 1240 0 100

Misses in library cache during parse: 0
Optimizer goal: ALL_ROWS
Parsing user: APPS (ID=44)

Rows Row Source Operation
------- ---------------------------------------------------
0 STATEMENT
100 PARTITION RANGE ALL PARTITION: 1 94 (cr=1240 pr=0 pw=0 time=10802 us)
100 PARTITION HASH SINGLE PARTITION: KEY KEY (cr=1240 pr=0 pw=0 time=12343 us)
100 TABLE ACCESS FULL PARTITION_TEST_TAB PARTITION: (cr=1240 pr=0 pw=0 time=11913 us)

-- ํŒŒํ‹ฐ์…˜ ํ‚ค์—์„œ ์„ ๋‘ ์—†์ด ํ›„๋ฐœ๋งŒ ๋“ค์–ด์˜ค๊ฒŒ ๋˜๋ฉด ๋น„ํšจ์œจ์ 

2. Index Ragne Scan
1) ์ธ๋ฑ์Šค ์ƒ์„ฑ

โ‘  ์ผ๋ฐ˜ ํ…Œ์ด๋ธ”
CREATE INDEX APPS.NORMAL_TEST_TAB_N1 ON APPS.NORMAL_TEST_TAB (MON_P1)
TABLESPACE APPS_TS_TX_IDX COMPUTE STATISTICS PARALLEL 6;
CREATE INDEX APPS.NORMAL_TEST_TAB_N2 ON APPS.NORMAL_TEST_TAB (MON_P1, GRP_P2)
TABLESPACE APPS_TS_TX_IDX COMPUTE STATISTICS PARALLEL 6;
CREATE INDEX APPS.NORMAL_TEST_TAB_N3 ON APPS.NORMAL_TEST_TAB (CNT_N1)
TABLESPACE APPS_TS_TX_IDX COMPUTE STATISTICS PARALLEL 6;

ALTER INDEX APPS.NORMAL_TEST_TAB_N1 NOPARALLEL;
ALTER INDEX APPS.NORMAL_TEST_TAB_N2 NOPARALLEL;
ALTER INDEX APPS.NORMAL_TEST_TAB_N3 NOPARALLEL;

โ‘ก ํŒŒํ‹ฐ์…˜ ํ…Œ์ด๋ธ”
-- Local Prefixed Index
CREATE INDEX APPS.PARTITION_TEST_TAB_N1 ON APPS.PARTITION_TEST_TAB (MON_P1)
TABLESPACE APPS_TS_TX_IDX COMPUTE STATISTICS PARALLEL 6 LOCAL;
CREATE INDEX APPS.PARTITION_TEST_TAB_N2 ON APPS.PARTITION_TEST_TAB (MON_P1, GRP_P2)
TABLESPACE APPS_TS_TX_IDX COMPUTE STATISTICS PARALLEL 6 LOCAL;

-- Global Prefixed Index
CREATE INDEX APPS.PARTITION_TEST_TAB_N3 ON APPS.PARTITION_TEST_TAB (CNT_N1)
GLOBAL PARTITION BY RANGE(CNT_N1) (PARTITION P1 VALUES LESS THAN (100000),
PARTITION P2 VALUES LESS THAN (200000),
PARTITION P3 VALUES LESS THAN (300000),
PARTITION P4 VALUES LESS THAN (400000),
PARTITION P5 VALUES LESS THAN (500000),
PARTITION P6 VALUES LESS THAN (600000),
PARTITION P7 VALUES LESS THAN (700000),
PARTITION P8 VALUES LESS THAN (800000),
PARTITION P9 VALUES LESS THAN (900000),
PARTITION P10 VALUES LESS THAN (1000000),
PARTITION P11 VALUES LESS THAN (MAXVALUE))
TABLESPACE APPS_TS_TX_IDX COMPUTE STATISTICS PARALLEL 6;

ALTER INDEX APPS.PARTITION_TEST_TAB_N1 NOPARALLEL;
ALTER INDEX APPS.PARTITION_TEST_TAB_N2 NOPARALLEL;
ALTER INDEX APPS.PARTITION_TEST_TAB_N3 NOPARALLEL;


3) ํ†ต๊ณ„์ •๋ณด

โ‘  ์ผ๋ฐ˜ ํ…Œ์ด๋ธ”
NORMAL_TEST_TAB
---------------
Rows=997,141 Blocks=3,032
Empty Blocks=0 Avg Space=0
Chain Count=0 Avg Row Length=16
Avg Space Freelist Blocks=0 Freelist Blocks=0
Sample Size=54,167 Last Analyze=2008/08/24
Partitioned=NO

Column Name Nullable Column Type Distinct Buckets
-------------------------------- -------- ------------- ---------- ----------
MON_P1 DATE 101 1
GRP_P2 NUMBER 9,999 1
CNT_N1 NUMBER 997,141 1

INDEX
-----------------------------------------------------------------------------
NORMAL_TEST_TAB_N1 : MON_P1
Type=NORMAL, Uniq=No, Distinct=100, Rows=1,000,000, Last Analyze=2008/08/24
NORMAL_TEST_TAB_N2 : MON_P1 + GRP_P2
Type=NORMAL, Uniq=No, Distinct=10,000, Rows=1,000,000, Last Analyze=2008/08/24
NORMAL_TEST_TAB_N3 : CNT_N1
Type=NORMAL, Uniq=No, Distinct=1,000,000, Rows=1,000,000, Last Analyze=2008/08/24

โ‘ก ํŒŒํ‹ฐ์…˜ ํ…Œ์ด๋ธ”
PARTITION_TEST_TAB
------------------
Rows=998,668 Blocks=74,646
Empty Blocks=0 Avg Space=0
Chain Count=0 Avg Row Length=16
Avg Space Freelist Blocks=0 Freelist Blocks=0
Sample Size=56,777 Last Analyze=2008/08/24
Partitioned=YES

Column Name Nullable Column Type Distinct Buckets
-------------------------------- -------- ------------- ---------- ----------
MON_P1 DATE 101 1
GRP_P2 NUMBER 9,994 1
CNT_N1 NUMBER 998,668 1

INDEX
-----------------------------------------------------------------------------
PARTITION_TEST_TAB_N1 : MON_P1
Partition=LOCAL NON_PREFIXED
Type=NORMAL, Uniq=No, Distinct=8, Rows=1,000,000, Last Analyze=2008/08/24
PARTITION_TEST_TAB_N2 : MON_P1 + GRP_P2
Partition=LOCAL PREFIXED
Type=NORMAL, Uniq=No, Distinct=10,000, Rows=1,000,000, Last Analyze=2008/08/24
PARTITION_TEST_TAB_N3 : CNT_N1
Partition=GLOBAL PREFIXED
Type=NORMAL, Uniq=No, Distinct=1,000,000, Rows=1,000,000, Last Analyze=2008/08/24


4) ํ…Œ์ŠคํŠธ

โ‘  ์ผ๋ฐ˜ ํ…Œ์ด๋ธ”
SELECT *
FROM NORMAL_TEST_TAB
WHERE MON_P1 = :B1 -- 2007/01/01
AND GRP_P2 = :B2 -- 841000
;

Call Count CPU Time Elapsed Time Disk Query Current Rows
------- ------ -------- ------------ ---------- ---------- ---------- ----------
Parse 1 0.000 0.000 0 0 0 0
Execute 1 0.000 0.000 0 0 0 0
Fetch 11 0.000 0.000 0 24 0 100
------- ------ -------- ------------ ---------- ---------- ---------- ----------
Total 13 0.000 0.001 0 24 0 100

Misses in library cache during parse: 0
Optimizer goal: ALL_ROWS
Parsing user: APPS (ID=44)

Rows Row Source Operation
------- ---------------------------------------------------
0 STATEMENT
100 TABLE ACCESS BY INDEX ROWID NORMAL_TEST_TAB (cr=24 pr=0 pw=0 time=36 us)
100 INDEX RANGE SCAN NORMAL_TEST_TAB_N2 (cr=13 pr=0 pw=0 time=621 us)(Object ID 2885525)

SELECT *
FROM NORMAL_TEST_TAB
WHERE CNT_N1 = :B1 -- 900000
;

Call Count CPU Time Elapsed Time Disk Query Current Rows
------- ------ -------- ------------ ---------- ---------- ---------- ----------
Parse 1 0.000 0.000 0 0 0 0
Execute 1 0.000 0.000 0 0 0 0
Fetch 2 0.000 0.000 0 5 0 1
------- ------ -------- ------------ ---------- ---------- ---------- ----------
Total 4 0.000 0.000 0 5 0 1

Misses in library cache during parse: 0
Optimizer goal: ALL_ROWS
Parsing user: APPS (ID=44)

Rows Row Source Operation
------- ---------------------------------------------------
0 STATEMENT
1 TABLE ACCESS BY INDEX ROWID NORMAL_TEST_TAB (cr=5 pr=0 pw=0 time=40 us)
1 INDEX RANGE SCAN NORMAL_TEST_TAB_N3 (cr=4 pr=0 pw=0 time=36 us)(Object ID 2885526)

โ‘ก ํŒŒํ‹ฐ์…˜ ํ…Œ์ด๋ธ”
SELECT *
FROM PARTITION_TEST_TAB
WHERE MON_P1 = :B1 -- 2007/01/01
AND GRP_P2 = :B2 -- 841000
;

Call Count CPU Time Elapsed Time Disk Query Current Rows
------- ------ -------- ------------ ---------- ---------- ---------- ----------
Parse 1 0.000 0.000 0 0 0 0
Execute 1 0.000 0.000 0 0 0 0
Fetch 11 0.000 0.001 0 23 0 100
------- ------ -------- ------------ ---------- ---------- ---------- ----------
Total 13 0.000 0.001 0 23 0 100

Misses in library cache during parse: 0
Optimizer goal: ALL_ROWS
Parsing user: APPS (ID=44)

Rows Row Source Operation
------- ---------------------------------------------------
0 STATEMENT
100 PARTITION RANGE SINGLE PARTITION: KEY KEY (cr=23 pr=0 pw=0 time=71 us)
100 PARTITION HASH SINGLE PARTITION: KEY KEY (cr=23 pr=0 pw=0 time=55 us)
100 TABLE ACCESS BY LOCAL INDEX ROWID PARTITION_TEST_TAB PARTITION: KEY KEY (cr=23 pr=0 pw=0 time=46 us)
100 INDEX RANGE SCAN PARTITION_TEST_TAB_N2 PARTITION: KEY KEY (cr=12 pr=0 pw=0 time=826 us)(Object ID 2895022)

-- Global Prefixed Index
SELECT *
FROM PARTITION_TEST_TAB
WHERE CNT_N1 = :B1 -- 900000
;

Call Count CPU Time Elapsed Time Disk Query Current Rows
------- ------ -------- ------------ ---------- ---------- ---------- ----------
Parse 1 0.000 0.000 0 0 0 0
Execute 1 0.000 0.000 0 0 0 0
Fetch 2 0.000 0.000 0 4 0 1
------- ------ -------- ------------ ---------- ---------- ---------- ----------
Total 4 0.000 0.000 0 4 0 1

Misses in library cache during parse: 0
Optimizer goal: ALL_ROWS
Parsing user: APPS (ID=44)

Rows Row Source Operation
------- ---------------------------------------------------
0 STATEMENT
1 PARTITION RANGE SINGLE PARTITION: KEY KEY (cr=4 pr=0 pw=0 time=49 us)
1 TABLE ACCESS BY GLOBAL INDEX ROWID PARTITION_TEST_TAB PARTITION: ROW LOCATION ROW LOCATION (cr=4 pr=0 pw=0 time=35 us)
1 INDEX RANGE SCAN PARTITION_TEST_TAB_N3 PARTITION: KEY KEY (cr=3 pr=0 pw=0 time=30 us)(Object ID 2904517)
;

-- Local Non-Prefixed Index
DROP INDEX APPS.PARTITION_TEST_TAB_N3;

CREATE INDEX APPS.PARTITION_TEST_TAB_N3 ON APPS.PARTITION_TEST_TAB (CNT_N1) TABLESPACE APPS_TS_TX_IDX COMPUTE STATISTICS PARALLEL 6 LOCAL;

-- FULL COLUMN
SELECT *
FROM PARTITION_TEST_TAB
WHERE MON_P1 = :B1 -- 2007/01/01
AND GRP_P2 = :B2 -- 841000
AND CNT_N1 = :B3 -- 840936
;

Call Count CPU Time Elapsed Time Disk Query Current Rows
------- ------ -------- ------------ ---------- ---------- ---------- ----------
Parse 1 0.000 0.000 0 0 0 0
Execute 1 0.000 0.000 0 0 0 0
Fetch 2 0.000 0.000 0 4 0 1
------- ------ -------- ------------ ---------- ---------- ---------- ----------
Total 4 0.000 0.000 0 4 0 1

Misses in library cache during parse: 0
Optimizer goal: ALL_ROWS
Parsing user: APPS (ID=44)

Rows Row Source Operation
------- ---------------------------------------------------
0 STATEMENT
1 PARTITION RANGE SINGLE PARTITION: KEY KEY (cr=4 pr=0 pw=0 time=99 us)
1 PARTITION HASH SINGLE PARTITION: KEY KEY (cr=4 pr=0 pw=0 time=73 us)
1 TABLE ACCESS BY LOCAL INDEX ROWID PARTITION_TEST_TAB PARTITION: KEY KEY (cr=4 pr=0 pw=0 time=55 us)
1 INDEX RANGE SCAN PARTITION_TEST_TAB_N3 PARTITION: KEY KEY (cr=3 pr=0 pw=0 time=41 us)(Object ID 2904529)

-- ํ›„๋ฐœ ์—†์ด(์„ ๋‘ํ‚ค๊ฐ€ ์—†์œผ๋ฉด PARALLEL ์ฒ˜๋ฆฌํ•  ๋–„ ๋ณด์ด๋Š” ์‹คํ–‰๊ณ„ํš ๋‚˜์˜ด)
SELECT *
FROM PARTITION_TEST_TAB
WHERE MON_P1 = :B1 -- 2007/01/01
AND CNT_N1 = :B3 -- 840936
;

Call Count CPU Time Elapsed Time Disk Query Current Rows
------- ------ -------- ------------ ---------- ---------- ---------- ----------
Parse 1 0.000 0.000 0 0 0 0
Execute 1 0.000 0.018 0 200 0 0
Fetch 2 0.010 0.117 0 0 0 1
------- ------ -------- ------------ ---------- ---------- ---------- ----------
Total 4 0.010 0.135 0 200 0 1

Misses in library cache during parse: 0
Optimizer goal: ALL_ROWS
Parsing user: APPS (ID=44)

Rows Row Source Operation
------- ---------------------------------------------------
0 STATEMENT
1 PX COORDINATOR (cr=200 pr=0 pw=0 time=37561 us)
0 PX SEND QC (RANDOM) :TQ10000 (cr=0 pr=0 pw=0 time=0 us)
0 PX PARTITION HASH ALL PARTITION: 1 100 (cr=0 pr=0 pw=0 time=0 us)
0 TABLE ACCESS BY LOCAL INDEX ROWID PARTITION_TEST_TAB PARTITION: KEY KEY (cr=0 pr=0 pw=0 time=0 us)
0 INDEX RANGE SCAN PARTITION_TEST_TAB_N3 PARTITION: KEY KEY (cr=0 pr=0 pw=0 time=0 us)(Object ID 2904529)

-- ์„ ๋‘ ์—†์ด(์„ ๋‘ํ‚ค๊ฐ€ ์—†์œผ๋ฉด PARALLEL ์ฒ˜๋ฆฌํ•  ๋–„ ๋ณด์ด๋Š” ์‹คํ–‰๊ณ„ํš ๋‚˜์˜ด)
SELECT *
FROM PARTITION_TEST_TAB
WHERE GRP_P2 = :B2 -- 841000
AND CNT_N1 = :B3 -- 840936
;

Call Count CPU Time Elapsed Time Disk Query Current Rows
------- ------ -------- ------------ ---------- ---------- ---------- ----------
Parse 1 0.000 0.000 0 0 0 0
Execute 1 0.000 0.009 0 188 0 0
Fetch 2 0.010 0.135 0 0 0 1
------- ------ -------- ------------ ---------- ---------- ---------- ----------
Total 4 0.010 0.144 0 188 0 1

Misses in library cache during parse: 0
Optimizer goal: ALL_ROWS
Parsing user: APPS (ID=44)

Rows Row Source Operation
------- ---------------------------------------------------
0 STATEMENT
1 PX COORDINATOR (cr=188 pr=0 pw=0 time=46595 us)
0 PX SEND QC (RANDOM) :TQ10000 (cr=0 pr=0 pw=0 time=0 us)
0 PX PARTITION HASH SINGLE PARTITION: KEY KEY (cr=0 pr=0 pw=0 time=0 us)
0 TABLE ACCESS BY LOCAL INDEX ROWID PARTITION_TEST_TAB PARTITION: (cr=0 pr=0 pw=0 time=0 us)
0 INDEX RANGE SCAN PARTITION_TEST_TAB_N3 PARTITION: (cr=0 pr=0 pw=0 time=0 us)(Object ID 2904529)


์ถœ์ฒ˜ : http://docs.oracle.com/cd/E11882_01/server.112/e10819/intro.htm#BHCHIAFE

๋ฒˆ์—ญ : TexasCowboy 

Moving From Standard Edition to Enterprise Edition of Oracle Database

If you have Oracle Database Standard Edition at a release earlier than the new Oracle Database 11g release, then you can change it to Oracle Database Enterprise Edition by installing Oracle Enterprise Edition software and subsequently following the normal upgrade procedures, as described in Chapter 3, "Upgrading to the New Release of Oracle Database.".

Caution:

Performing this procedure deinstalls the Standard Edition software and results in deleting database files that exist under the Oracle home. Therefore, you must back up any database files under the current Oracle home that you need to keep. This is explained in steps 4 and 5. Also refer to "Known Issue with the Deinstallation Tool for Release 11.2.0.4".

To change your existing Standard Edition database to an Enterprise Edition database 

  1. Ensure that the release number of your Standard Edition server software is the same release as Enterprise Edition server software.
    ์‚ฌ์šฉ์ค‘์ธ ์Šคํƒ ๋‹ค๋“œ ์—๋””์…˜ ๋ฆด๋ฆฌ์ฆˆ ๋ฒˆํ˜ธ์™€ ์„ค์น˜ํ•˜๋ ค๋Š” ์—”ํ„ฐํ”„๋ผ์ด์ฆˆ ์—๋””์…˜ ๋ฆด๋ฆฌ์ฆˆ ๋ฒˆํ˜ธ๊ฐ€ ๋™์ผํ•œ์ง€ ํ™•์ธํ•ด๋ผ. ( ๋™์ผํ•˜์ง€ ์•Š์œผ๋ฉด ์•ˆ๋œ๋‹ค. )

    For example, if your Standard Edition server software is release 11.1.0.6, then you must upgrade to release 11.1.0.6 of Enterprise Edition.
     

  2. Shut down your database.
    ๋ฐ์ดํƒ€๋ฒ ์ด์Šค๋ฅผ ์ค‘์ง€์‹œํ‚จ๋‹ค.
     

  3. If your operating system is Windows, then stop all Oracle services, including the OracleServiceSID Oracle service, where SID is the instance name.
    ์œˆ๋„์šฐ ์šด์˜์ฒด์ œ๋ฅผ ์‚ฌ์šฉ์ค‘์ด๋ผ๋ฉด OracleServiceSID Oracle Service๋ฅผ ํฌํ•จํ•œ ๋ชจ๋“  ์˜ค๋ผํด ์„œ๋น„์Šค๋ฅผ ์ค‘์ง€์‹œ์ผœ์•ผ ํ•œ๋‹ค.
     

  4. Make a backup copy of files under $Oracle_Home/network/admin. This ensures that the listener is configured after you complete the steps in this procedure.
    $Oracle_Home/network/admin ํด๋” ์•ˆ์— ๋ฐฑ์—…ํŒŒ์ผ์„ ๋„ฃ๋Š”๋‹ค.
     

  5. Back up all database files and data under the current Oracle home that you need to keep.

    • On Linux, back up $Oracle_Home/dbs/.

    • On Windows, back up $Oracle_Home/database/.

     


    DBํŒŒ์ผ์„ ๋ชจ๋‘ ๋ฐฑ์—…ํ•œ๋‹ค.
     

     

  6. Edit the orabase_cleanup.lst file found in the Oracle_Home/utl directory and remove the "oradata" and "admin" entries. Refer to "Deinstallation of the Oracle home in the earlier release of Oracle Database may result in the deletion of the old Oracle base that was associated with it".
    Oracle_Home/utl ๋””๋ ‰ํ† ๋ฆฌ ์•ˆ์—์žˆ๋Š” orabase_cleanup.lst ํŒŒ์ผ์„ ์ˆ˜์ •ํ•ด์„œ oradata์™€ admin ๋ถ€๋ถ„์„ ์ง€์›Œ์ค€๋‹ค.
     

  7. Deinstall the Standard Edition server software.

    Run the deinstall tool from the Oracle home. The deinstall tool is located in the $ORACLE_HOME/deinstall directory for UNIX platforms, and in the ORACLE_HOME\deinstall directory for Windows platforms.

    IMPORTANT:

    The deinstall tool deletes all existing database files that reside under Oracle home, including data in the database. Therefore, Oracle recommends that you retain a current backup of your data.
    ์Šคํƒ ๋‹ค๋“œ ์—๋””์…˜์„ deinstallํ•œ๋‹ค. Oracle Home๋””๋ ‰ํ† ๋ฆฌ ์•ˆ์— deinstall๋””๋ ‰ํ† ๋ฆฌ๊ฐ€ ์žˆ๊ณ  ๊ทธ ์•ˆ์—์„œ deinstall์‹คํ–‰ํŒŒ์ผ์„ ์ฐพ์„ ์ˆ˜ ์žˆ์„ ๊ฒƒ์ด๋‹ค. deinstall๋ช…๋ น์€ ํ˜„์กดํ•˜๋Š” Oracle Home๋ฐ‘์˜ ๋ชจ๋“  DBํŒŒ์ผ๊ณผ ๋ฐ์ดํƒ€๋ฅผ ์‚ญ์ œํ•˜๋ฏ€๋กœ ๋ฐฑ์—…์„ ํ•ด๋‘๋Š” ๊ฒƒ์ด ์ข‹์„ ๊ฒƒ์ด๋‹ค.
     

  8. Install Enterprise Edition server software using Oracle Universal Installer (OUI).

    Select the same Oracle home that was used for the Standard Edition that you uninstalled. During the installation, be sure to select Enterprise Edition. When prompted, choose Software Only from the Database Configuration screen.
    OUI๋ฅผ ์ด์šฉํ•ด์„œ ์—”ํ„ฐํ”„๋ผ์ด์ฆˆ ์—๋””์…˜์„ ์„ค์น˜ํ•œ๋‹ค. ์Šคํƒ ๋‹ค๋“œ ์—๋””์…˜์ด ์‚ฌ์šฉํ–ˆ๋˜ Oracle Home๊ณผ ๋™์ผํ•œ ๊ฒฝ๋กœ๋ฅผ Oracle Home์œผ๋กœ ์ง€์ •ํ•œ๋‹ค.
     

  9. Start up your database.
    ๋ฐ์ดํƒ€๋ฒ ์ด์Šค๋ฅผ ์‹œ์ž‘ํ•œ๋‹ค.

Your database is now upgraded to Enterprise Edition.

Known Issue with the Deinstallation Tool for Release 11.2.0.4

Deinstallation of the Oracle home in the earlier release of Oracle Database may result in the deletion of the old Oracle base that was associated with it
Cause: After upgrading from Oracle Database release 11.2.0.1 or 11.2.0.2 to release 11.2.0.4, deinstallation of the Oracle home in the earlier release of Oracle Database may result in the deletion of the old Oracle base that was associated with it. This may also result in the deletion of data files, audit files, etc., which are stored under the old Oracle base. Important Note: This issue is applicable for upgrades from release 11.2.0.1 or 11.2.0.2 to 11.2.0.4, but is not applicable for upgrading from release 11.2.0.3 to 11.2.0.4.
Action: Before deinstalling the Oracle home in the earlier release, edit the orabase_cleanup.lst file found in the $Oracle_Home/utl directory and remove the "oradata" and "admin" entries. Then proceed with the deinstallation.


๋ญ ์ด๋Ÿฐ ์ •๋ณด๋“ค์ด์•ผ ์„ค์น˜ํ•  ๋•Œ ๋‹ค ์•Œ๊ณ  ์„ค์น˜ํ•˜์ง€๋งŒ ๋‚˜์ค‘์— ๊นŒ๋จน๋Š” ๊ฒฝ์šฐ๋„ ์žˆ์œผ๋‹ˆ ์•Œ์•„๋‘๋ฉด ์ข‹์€์ •๋ณด๋ผ ์ƒ๊ฐํ•œ๋‹ค.

select * from v$version;


DBA๊ถŒํ•œ์„ ๊ฐ–๊ณ  ์žˆ๋Š” ์‚ฌ์šฉ์ž๊ฐ€ ์œ„ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™์€ ๊ฒฐ๊ณผ๊ฐ€ ๋‚˜์˜ฌ ๊ฒƒ์ด๋‹ค.


๊ฒฝ์šฐ์— ๋”ฐ๋ผ


1. ์—”ํ„ฐํ”„๋ผ์ด์ฆˆ ์ธ๊ฒฝ์šฐ

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE    11.2.0.1.0      Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
 

2. ์Šคํƒ ๋‹ค๋“œ ์ธ๊ฒฝ์šฐ

Oracle Database 11g Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE    11.2.0.1.0      Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production

์˜ค๋ผํด DB๋ฅผ ๋ฐฑ์—…ํ• ๋•Œ exp๋ช…๋ น์–ด๋ฅผ ์ด์šฉํ•  ๋•Œ ์•„๋ž˜์™€ ๊ฐ™์€ ์˜ค๋ฅ˜๋ฉ”์‹œ์ง€๋ฅผ ๋ณธ ์ ์ด ์žˆ์„ ๊ฒƒ์ด๋‹ค.

 

EXP-00091 Exporting questionable statistics

 

์ด ์—๋Ÿฌ๋Š” data๋ฅผ exportํ•  ๋•Œ ํ•ด๋‹น ๋ฐ์ดํƒ€์™€ ๊ด€๋ จ๋œ optimizer statistics๋ฅผ ํ•จ๊ป˜ exportํ•˜๋ ค๊ณ  ํ•  ๋•Œ ๋ฐœ์ƒํ•œ๋‹ค๊ณ  ํ•œ๋‹ค. export๋ฅผ ํ•œ๋‹ค๋Š” ๊ฒƒ์€ ๋‹จ์ˆœํžˆ ๋ฐฑ์—…์šฉ๋„๋กœ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ๋„ ์žˆ๊ฒ ์ง€๋งŒ ๋‹ค๋ฅธ ์„œ๋ฒ„๋กœ ๋ฐ์ดํƒ€๋ฅผ ์ด์ „ ํ•  ๋•Œ ์‚ฌ์šฉํ•˜๊ธฐ๋„ ํ•œ๋‹ค. ๋ฐ์ดํ„ฐ๋ฅผ ์ด์ „ํ•˜๊ฒŒ๋˜๋ฉด ์˜ค๋ผํด์€ ๋ณ€๊ฒฝ๋œ ํ™˜๊ฒฝ์— ๋งž๊ฒŒ๋” plan์„ ์„ธ์›Œ์•ผ ํ•˜๋Š”๋ฐ ๊ธฐ์กด์˜ ํ†ต๊ณ„๋ฅผ ํ•จ๊ป˜ exportํ•˜๊ฒŒ๋˜๋ฉด plan์„ ์ •ํ•  ๋•Œ ์ตœ์ ํ™”๋œ plan์„ ์„ธ์šฐ๋Š”๋ฐ ์˜ํ–ฅ์„ ๋ฏธ์น  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ๊ฒฝ๊ณ ๋ฉ”์‹œ์ง€๋ฅผ ๋„์›Œ์ฃผ๋Š” ๊ฒƒ์ด๋‹ค.

 

ํ†ต๊ณ„๋ฅผ ์ œ์™ธํ•˜๊ณ  ๋ฐ์ดํƒ€๋งŒ exportํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” exp๋ช…๋ น์–ด ์˜ต์…˜ ์ค‘์— statistics=none์ด๋ผ๋Š” ์˜ต์…˜์„ ์ถ”๊ฐ€๋กœ ๋ถ™์—ฌ์ฃผ๋ฉด ๋œ๋‹ค. 

 

์ข€ ๋” ์ž์„ธํ•œ ์‚ฌํ•ญ์€ ์•„๋ž˜ ๋งํฌ๋ฅผ ์ฐธ์กฐํ•˜๊ธธ ๋ฐ”๋ž€๋‹ค.

http://www.dba-oracle.com/t_exp_00091_exporting_questionable_statistics.htm


๊ณ„์ • ์ƒ์„ฑ



create user ์œ ์ €๋„ค์ž„ identified by ํŒจ์Šค์›Œ๋“œ;
 

๊ถŒํ•œ ๋ถ€์—ฌ, ์กฐํšŒ

 resource, connect ๋Š” ์ผ๋ฐ˜์ ์ธ ๊ฒƒ์„ ๋‹ค ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. (DDL, DML ๋“ฑ)




grant resource, connect to ์œ ์ €๋„ค์ž„;
grant DBA to ์œ ์ €๋„ค์ž„;

select * from dba_sys_privs where grantee='์œ ์ €ID';

ํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค ์ง€์ •




alter user ์œ ์ €๋„ค์ž„ default tablespace ํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค๋ช…;
alter user ์œ ์ €๋„ค์ž„ temporary tablespace ์ž„์‹œํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค๋ช…;
 

๊ณ„์ • ์‚ญ์ œ

 cascade ๋ฅผ ๋ช…์‹œํ•˜๋ฉด ์œ ์ €๋„ค์ž„๊ณผ ๊ด€๋ จ๋œ ๋ชจ๋“  ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์Šคํ‚ค๋งˆ๊ฐ€ ๋ฐ์ดํ„ฐ ์‚ฌ์ „์œผ๋กœ๋ถ€ํ„ฐ ์‚ญ์ œ๋˜๊ณ  ๋ชจ๋“  ์Šคํ‚ค๋งˆ ๊ฐ์ฒด๋„ ๋ฌผ๋ฆฌ์ ์œผ๋กœ ์‚ญ์ œ๋œ๋‹ค.



drop user ์œ ์ €๋„ค์ž„ cascade;


1. Full ๋ฐฑ์—…(Full Level)

 

    1) Export ( ์˜ค๋ผํด DB ์ „์ฒด๊ฐ€ ๋ฐฑ์—…๋œ๋‹ค. ๋ชจ๋“  ํ…Œ์ด๋ธ” ์ŠคํŽ˜์ด์Šค, ์‚ฌ์šฉ์ž, ๊ฐ์ฒด, ๋ฐ์ดํ„ฐ๋“ค ํฌํ•จ ) 

 

[oracle@MyServer ~]$ exp userid=system/manager statistics=none file='./full.dmp' full=y


    2) Import

 

[oracle@MyServer ~]$ imp userid=system/system statistics=none file='./full.dmp' full=y  

 

   3) Import ์‹œ ์ฃผ์˜์‚ฌํ•ญ

๊ธฐ์กด DB์—์„œ export ๋‹น์‹œ์™€ ๋™์ผํ•œ SID๋ฅผ ๊ฐ€์ง€๋Š” DB๊ฐ€ ์กด์žฌํ•ด์•ผ ํ•œ๋‹ค. 

๊ทธ๋ ‡์ง€ ์•Š์„๊ฒฝ์šฐ import ์ค‘์— ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค.

 

 

2. ์‚ฌ์šฉ์ž๋‹จ์œ„ ๋ฐฑ์—…(User Level)

    

    1) Export ( ์‚ฌ์šฉ์ž๊ฐ€ ์†Œ์œ ํ•˜๊ณ  ์žˆ๋Š” ๊ฐ์ฒด, ๋ฐ์ดํ„ฐ๋“ค ํฌํ•จ ) 

 

[oracle@MyServer ~]$ exp userid=scott/tiger statistics=none file='./scott.dmp'  

 

    2) Import

 

[oracle@MyServer ~]$ imp userid=system/manager owner=scott statistics=none file='./scott.dmp'  

 

   3) Import ์‹œ ์ฃผ์˜์‚ฌํ•ญ

     ์ด๊ด€ํ•˜๋ ค๋Š” ์„œ๋ฒ„๋‚˜ ๊ธฐ์กด DB์— ๋™์ผํ•œ ์‚ฌ์šฉ์ž ๊ณ„์ •์ด ์ƒ์„ฑ์ด ๋˜์–ด ์žˆ์–ด์•ผ ํ•˜๋ฉฐ, TableSapce๊ฐ€ ์žˆ์–ด์•ผ ํ•œ๋‹ค.  

     SID๋Š” ๋‹ฌ๋ผ๋„ ์ƒ๊ด€์—†๋‹ค.

 

   4) Import ์ ˆ์ฐจ.

      - DB ์ƒ์„ฑ

      - TableSpace ์ƒ์„ฑ

      - ๊ณ„์ • ์ƒ์„ฑ ๋ฐ TableSpace ์ ‘๊ทผ ๊ถŒํ•œ ์ถ”๊ฐ€.

      - imp ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•œ ๋ฐ์ดํ„ฐ import

 

 

# exp, imp๋ช…๋ น์–ด์˜ ์˜ต์…˜์— ๋Œ€ํ•ด์„œ ์•Œ๊ณ ์‹ถ์œผ๋ฉด ์•„๋ž˜์™€ ๊ฐ™์€ ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค. 

 

[oracle@MyServer ~]$ imp help=y 

 


1. ๋‚˜ ์ž์‹ ์ด ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ํ…Œ์ด๋ธ”์„ ์กฐํšŒํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด 

select * from user_tables;

 

2. dba๊ถŒํ•œ์„ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ์‚ฌ์šฉ์ž๊ฐ€ ๋‹ค๋ฅธ ์‚ฌ์šฉ์ž์˜ ํ…Œ์ด๋ธ”์„ ์กฐํšŒํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด

select * from dba_tables where owner='์‚ฌ์šฉ์žID'; 


์ด ์˜ค๋ฅ˜๋Š” Blobํ˜•ํƒœ์˜ ๋ฐ์ดํƒ€๋ฅผ String๋ณ€์ˆ˜์— ๋ฐ›์•„์˜ค๋ ค๊ณ  ํ• ๋•Œ ๋ฐœ์ƒํ•œ๋‹ค.

Blobํ˜•ํƒœ์˜ ๋ฐ์ดํƒ€๋ฅผ ๋ฐ›์•„์˜ฌ๋•Œ๋Š” String๋ณ€์ˆ˜ ๋Œ€์‹ ์— byte[]๋ฅผ ์จ์•ผํ•œ๋‹ค.