--ORACLE
SELECT 'TEST_TABLE' AS TBLID
, COUNT(*) AS CNT
, 0
+ NVL(SUM(LENGTH(TRIM(COL_CHR))),0)
+ NVL(ROUND(SUM(COL_NUM)),0)
+ NVL(ROUND(SUM(TO_DATE(TO_CHAR(COL_DAT,'YYYYMMDD'),'YYYYMMDD') - TO_DATE('20000101','YYYYMMDD'))),0)
+ NVL(SUM(LENGTH(CAST(DBMS_LOB.SUBSTR(COL_CLOB,2000,1) AS NVARCHAR2(2000)))),0)
AS CHK_SUM
FROM TEST_TABLE
;
* 오라클내에서 char 값까지 검증할 경우 ORA_HASH 함수 이용
--MSSQL
SELECT 'TEST_TABLE' AS TBLID
, COUNT(*) AS CNT
, 0
+ ISNULL(SUM(CAST(LEN(LTRIM(COL_CHR)) AS NUMERIC)),0)
+ ISNULL(SUM(COL_NUM),0)
+ ISNULL(SUM(CAST(DATEDIFF(DAY, CONVERT(DATE, '20000101', 112), CONVERT(DATE, CONVERT(VARCHAR(8), COL_DAT, 112), 112)) AS NUMERIC)),0)
+ ISNULL(SUM(CAST(LEN(REPLACE(CAST(COL_CLOB AS NVARCHAR(2000)),' ','.')) AS NUMERIC)),0)
AS CHK_SUM
FROM TEST_TABLE
;
'전산Tip > Oracle' 카테고리의 다른 글
[ORACLE] 스키마 이행 검증 (0) | 2019.04.24 |
---|---|
ORACLE TABLE PRIVILEGE (0) | 2019.04.12 |
[ORACLE] 문자열을 구분자 기준으로 ROW로 변환하는 테이블 함수 (0) | 2019.04.11 |