2006년 12월 18일 월요일

MS-SQL에서 Oracle로 데이터 복제 사용시 발생되는 오류

http://cafe.naver.com/sanovice/264

MS-SQL에서 Oracle로 데이터 복제 사용시 발생되는 오류중

MS-SSQL에서는 ''가 NULL로 인식되지 않지만 Oracle에서는 ''가 NULL로 인식된다.



따라서 필요에 따라서 Oracle의 Not NULL컬럼을 NULL 허용으로 변경하여야 할 경우

아래 쿼리문을 참조하면 쉽게 변경할 수 있다.



select bb.table_name, bb.column_name, substr(bb.column_name, -3), cc.column_id, cc.data_type, cc.nullable,
'alter table ' || bb.table_name || ' modify ( ' || cc.column_name || ' NULL ); ' as mod_query
from user_constraints aa, user_cons_columns bb, USER_TAB_COLS cc
where aa.constraint_name = bb.constraint_name
and bb.table_name = cc.table_name (+)
and bb.column_name = cc.column_name (+)
and aa.owner = '변경할 사용자 계정'
and aa.constraint_type = 'C' /* 체크 옵션만 적용 */
and upper(bb.column_name) <> 'MSREPL_TRAN_VERSION' /* 특정컬럼(MS-SQL 복제용컬럼)은 제외 */
and cc.data_type like '%CHAR%' /* 문자형 컬럼만 적용 */
and substr(bb.column_name, -3) not in ('_ID', '_CD') /* 끝자리가 일치하는 문자 제외 처리 */
order by bb.table_name, cc.column_id ;