/****************************************************************
* grapro : 컬럼별 최대값 최소값 구하기 (하단 펑션 추가 필요)
*****************************************************************/
CREATE OR REPLACE FUNCTION TEST_RAW_TO_VALUE(I_RAW RAW, I_DATA_TYPE IN VARCHAR2)
RETURN VARCHAR2
AS
M_V VARCHAR2(4000);
M_C CHAR(4000);
M_N NUMBER;
M_D DATE;
BEGIN
IF I_DATA_TYPE='NUMBER' THEN
DBMS_STATS.CONVERT_RAW_VALUE(I_RAW,M_N);
M_V := TO_CHAR(M_N);
ELSIF I_DATA_TYPE='DATE' THEN
DBMS_STATS.CONVERT_RAW_VALUE(I_RAW,M_D);
M_V := TO_CHAR(M_D);
ELSIF I_DATA_TYPE='VARCHAR2' THEN
DBMS_STATS.CONVERT_RAW_VALUE(I_RAW,M_V);
M_V := TO_CHAR(M_V);
ELSIF I_DATA_TYPE='CHAR' THEN
DBMS_STATS.CONVERT_RAW_VALUE(I_RAW,M_C);
M_V := RTRIM(M_C);
ELSE
M_V := 'N/A';
END IF;
RETURN M_V;
END;
SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_LENGTH, NUM_DISTINCT
, TEST_RAW_TO_VALUE(LOW_VALUE,DATA_TYPE) MIN_VAL
, TEST_RAW_TO_VALUE(HIGH_VALUE,DATA_TYPE) MAX_VAL
FROM COLS A
WHERE COLUMN_NAME LIKE '%YYYY%'
OR COLUMN_NAME LIKE '%년%'
ORDER BY TABLE_NAME, COLUMN_ID
;
'전산Tip > Oracle' 카테고리의 다른 글
Opatch (2) | 2008.09.24 |
---|---|
오라클 옵티마이져의 최적화 수행원리 (0) | 2008.09.24 |
테이블별 용량 확인 (0) | 2008.09.23 |