기본 키가 없는 테이블의 경우 Database Migration Service가 변경 데이터 캡처 (CDC) 단계 중에 초기 스냅샷과 INSERT 문의 마이그레이션을 지원합니다.
누락된 UPDATE 및 DELETE 프로세스를 업데이트하려면 이 문서의 뒷부분 섹션을 참고하세요.
소스와 AlloyDB 대상 클러스터 간에 누락된 데이터 감지
기본 키가 없는 테이블을 식별합니다.
select tab.table_schema,
tab.table_name
from information_schema.tables tab
left join information_schema.table_constraints tco
on tab.table_schema = tco.table_schema
and tab.table_name = tco.table_name
and tco.constraint_type = 'PRIMARY KEY'
where tab.table_type = 'BASE TABLE'
and tab.table_schema not in ('pg_catalog', 'information_schema', 'pglogical')
and tco.constraint_name is null
order by table_schema,
table_name;
마이그레이션을 시작하기 전에 기본 키가 없는 모든 테이블에 대해 다음 쿼리를 사용하여 업데이트 또는 삭제가 있는지 확인합니다.
SELECT schemaname,
relname,
n_tup_ins,
n_tup_upd,
n_tup_del
FROM pg_stat_user_tables
WHERE schemaname NOT IN
('pglogical', 'pg_catalog', 'information_schema');
위치:
n_tup_ins: 삽입된 행 수
n_tup_upd: 업데이트된 행 수 (HOT 업데이트된 행 포함)
n_tup_del: 삭제된 행 수
이 결과를 별도의 테이블이나 파일에 저장합니다.
이전 설정이 완료되면 쿼리를 다시 실행합니다.
이 결과를 3단계의 결과와 비교합니다.
마이그레이션 중에 소스의 n_tup_upd 또는 n_tup_del 값에 차이가 있으면 소스에 일부 업데이트 또는 삭제가 있을 수 있습니다.
소스에서 AlloyDB 대상 인스턴스로 데이터를 수동으로 마이그레이션
소스 인스턴스와 AlloyDB 대상 인스턴스 간에 약간의 불일치가 감지되면 다음 옵션 중 하나를 사용하여 데이터를 마이그레이션할 수 있습니다.
옵션 1: 소스와 AlloyDB 대상 간에 데이터를 수동으로 비교하고 적절한 SQL 쿼리를 실행하여 소스와 복제본 간에 다른 데이터만 업데이트합니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-04-22(UTC)"],[[["This page provides debugging scripts and guidance for using AlloyDB, particularly focusing on data migration from PostgreSQL."],["Database Migration Service supports the initial snapshot and `INSERT` statements for tables without primary keys during migration, but manual steps are needed for `UPDATE` and `DELETE` operations."],["You can detect potential data discrepancies between the source and destination by identifying tables without primary keys and tracking `INSERT`, `UPDATE`, and `DELETE` activity using queries against `information_schema` and `pg_stat_user_tables`."],["If discrepancies are detected, manual migration options include comparing data and running SQL queries, utilizing `pg_dump` and `pg_restore`, or employing the Postgres `COPY` command, which might require pre-migration data cleanup on the replica."]]],[]]