Với Oracle 21c, Data Pump đã trở lên an toàn hơn với tính năng Checksums. Cụ thể như dưới đây.
Trong các bản phát hành trước đó, bất kỳ ai khả năng chỉnh sửa mã HEX, một chút kiến thức và một chút kiên nhẫn đều có thể lấy tệp xuất DataPump và thao tác nội dung trong đó.
[oracle@db192 ~]$ expdp userid=mcdonac/******@pdb1 directory=tmp dumpfile=scott schemas=scott
Export: Release 19.0.0.0.0 - Production on Mon Aug 16 11:30:42 2021
Version 19.12.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Starting "MCDONAC"."SYS_EXPORT_SCHEMA_01": userid=mcdonac/********@pdb1 directory=tmp dumpfile=scott schemas=scott
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type SCHEMA_EXPORT/STATISTICS/MARKER
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/TABLESPACE_QUOTA
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
. . exported "SCOTT"."EMP" 8.773 KB 14 rows
. . exported "SCOTT"."DEPT" 6.023 KB 4 rows
. . exported "SCOTT"."SALGRADE" 5.953 KB 5 rows
. . exported "SCOTT"."BONUS" 0 KB 0 rows
Master table "MCDONAC"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for MCDONAC.SYS_EXPORT_SCHEMA_01 is:
/tmp/scott.dmp
Job "MCDONAC"."SYS_EXPORT_SCHEMA_01" successfully completed at Mon Aug 16 11:31:19 2021 elapsed 0 00:00:35
Và sau đó chúng bị thay đổi bởi chương trình chỉnh sửa mã HEX

Và khi import vào, dữ liệu trong file Data Pump đã bị chỉnh sửa sẽ được import vào dẫn tới việc dữ liệu bị thay đổi mà ta có thể không biết được.
Import: Release 19.0.0.0.0 - Production on Mon Aug 16 11:40:06 2021
Version 19.12.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Master table "MCDONAC"."SYS_IMPORT_SCHEMA_01" successfully loaded/unloaded
Starting "MCDONAC"."SYS_IMPORT_SCHEMA_01": userid=mcdonac/********@pdb1 directory=tmp dumpfile=scott schemas=scott
Processing object type SCHEMA_EXPORT/USER
ORA-31684: Object type USER:"SCOTT" already exists
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/TABLESPACE_QUOTA
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "SCOTT"."EMP" 8.773 KB 14 rows
. . imported "SCOTT"."DEPT" 6.023 KB 4 rows
. . imported "SCOTT"."SALGRADE" 5.953 KB 5 rows
. . imported "SCOTT"."BONUS" 0 KB 0 rows
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type SCHEMA_EXPORT/STATISTICS/MARKER
Job "MCDONAC"."SYS_IMPORT_SCHEMA_01" completed with 1 error(s) at Mon Aug 16 11:40:25 2021 elapsed 0 00:00:18
[oracle@db192 tmp]$
SQL> select * from scott.emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 CONNOR SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 09-DEC-82 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 30
7876 ADAMS CLERK 7788 12-JAN-83 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10
14 rows selected.
Giả mạo thông tin với các kiểu dữ liệu khác chuỗi sẽ khó làm hơn 1 chút, nhưng vẫn có thể thực hiện được.
Bản Oracle 21c bây giờ cho phép bạn bảo vệ các tệp xuất DataPump khỏi việc chỉnh sửa đơn giản với tham số CHECKSUM. Đây là quy trình tương tự được lặp lại theo 21c.
[oracle@db21c ~]$ expdp userid=mcdonac/****@pdb1 directory=temp dumpfile=scott schemas=scott checksum=yes
Export: Release 21.0.0.0.0 - Production on Fri Aug 13 04:11:34 2021
Version 21.3.0.0.0
Copyright (c) 1982, 2021, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production
Starting "MCDONAC"."SYS_EXPORT_SCHEMA_01": userid=mcdonac/********@pdb1 directory=temp dumpfile=scott schemas=scott checksum=yes
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type SCHEMA_EXPORT/STATISTICS/MARKER
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/TABLESPACE_QUOTA
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
. . exported "SCOTT"."EMP" 8.773 KB 14 rows
. . exported "SCOTT"."DEPT" 6.023 KB 4 rows
. . exported "SCOTT"."SALGRADE" 5.953 KB 5 rows
. . exported "SCOTT"."BONUS" 0 KB 0 rows
Master table "MCDONAC"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
Generating checksums for dump file set
******************************************************************************
Dump file set for MCDONAC.SYS_EXPORT_SCHEMA_01 is:
/tmp/scott.dmp
Job "MCDONAC"."SYS_EXPORT_SCHEMA_01" successfully completed at Fri Aug 13 04:12:21 2021 elapsed 0 00:00:40
[oracle@db21c scripts]$ impdp userid=mcdonac/******@pdb1 directory=temp dumpfile=scott schemas=scott verify_checksum=yes
Import: Release 21.0.0.0.0 - Production on Sun Aug 15 23:53:29 2021
Version 21.3.0.0.0
Copyright (c) 1982, 2021, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production
ORA-39002: invalid operation
ORA-39412: file checksum error in dump file "/tmp/scott.dmp"
Lưu ý: Nếu bạn không chỉ định tham số VERIFY_CHECKSUM, quá trình import vẫn sẽ diễn ra, ngay cả khi ai đó đã can thiệp vào file Data Pump của bạn (và cuối cùng vẫn có tệp hợp lệ).
Leave a Review