Skip to main content
CYBERTEC Migrator Documentation
Support
latest Latest stable release View changelog ->
CYBERTEC Migrator › How-tos › Data Validation

Data Validation

6 min read

After the data stage, the Data Validation tab compares the migrated data of the PostgreSQL database with the Oracle database. It shows whether every row arrived correctly, and which rows are missing, additional or different.

Note
The data validation is available in the Professional and Enterprise editions.

Validation modes

ModeComparedSpeed
Row countsthe number of rows of every migrated tablefast, one COUNT(*) per table and database
Full comparison (default)the row counts and the values of every row, identified by the primary keyreads all rows of both databases

Start the validation with Start validation. It runs in the background, so you may leave the page and come back later.

Progress

While the validation is running, a progress bar shows

  • the percentage and the phase: Counting rows of all tables, then Comparing rows
  • the number of validated tables and, in the full comparison, the number of compared rows
  • the table that is currently validated and the elapsed time

The full comparison reads the rows in chunks of 5,000 rows. Cancel stops the validation after the current chunk and keeps the results of the tables validated so far. Only one validation per migration runs at a time, and the data can not be validated while a job of the migration is active.

Snapshot

By default the Oracle database is read at the snapshot (SCN) of the data stage, so changes made to the Oracle database after the data stage do not show up as differences. This requires the undo data of that snapshot. If it is no longer available (e.g. ORA-01555 or ORA-08181), the current data is compared and the result shows a note.

Choose Current data to compare with the current content of the Oracle database, e.g. after a delta load outside the Migrator.

How rows are compared

The full comparison orders the rows of both databases by the primary key and pages through them. For every chunk of Oracle rows it reads the PostgreSQL rows of the same key range, so rows that exist in only one of the databases are found as well. Strings are compared binary in both databases (NLS_COMP=BINARY in Oracle, COLLATE "C" in PostgreSQL).

Both databases convert the values into a comparable text, which accounts for the differences between Oracle and PostgreSQL:

Oracle data typeComparison
NUMBER, FLOAT, INTEGERas exact decimal numbers (12.50 equals 12.5)
BINARY_FLOAT, BINARY_DOUBLE, numbers migrated to double precisionwith a relative tolerance of 10-6
DATEwith seconds, so a DATE migrated to date shows lost times as differences
TIMESTAMPwith microseconds
TIMESTAMP WITH (LOCAL) TIME ZONEin UTC
VARCHAR2, NVARCHAR2exactly, empty strings equal NULL like in Oracle, NUL characters removed by the data stage are ignored
CHAR, NCHARwithout trailing blanks
CLOB, NCLOB, BLOBby length and MD5 hash of the content
RAWas hexadecimal value
INTERVAL YEAR TO MONTH, INTERVAL DAY TO SECONDas number of months or seconds

Large objects are hashed in the databases, so their content is not transferred. The complete content is hashed with DBMS_CRYPTO. Without the EXECUTE privilege on DBMS_CRYPTO, the length and the hash of the first 1,000 characters (CLOB) or 2,000 bytes (BLOB) are compared, and the result shows a note.

What is not compared

  • Rows of tables without a primary key, of tables transferred with a custom data query, and of tables whose primary key contains columns that can not be ordered the same way in both databases: only the row counts are compared, the result shows a note.
  • Columns of data types that can not be compared, e.g. LONG, BFILE, ROWID, user-defined types and JSON columns migrated to jsonb. They are listed per table with the reason. XMLTYPE columns are compared without the whitespace between tags, as the data stage transfers the XML indented.
  • Excluded tables and columns, and global temporary tables, whose rows are private to the sessions.

Results

When the validation has finished, the result shows whether all tables match, the number of matching, mismatching and failed tables, and the number of missing, additional and different rows.

Table statusMeaning
Matchthe row counts are equal and no row differs
Mismatchthe row counts differ, or rows are missing, additional or different
Errorthe table could not be validated, e.g. because it does not exist in PostgreSQL
Pendingthe table was not validated, because the validation was cancelled

Expand a table to see its notes, the columns that were not compared, and the first 20 differences:

  • Missing: the row of Oracle does not exist in PostgreSQL
  • Extra: the row of PostgreSQL does not exist in Oracle
  • Different: the row exists in both databases, the columns with different values are listed with both values
Tip
Differences are not always caused by the data transfer. They also reveal expressions that compute other values in PostgreSQL, e.g. of virtual columns you changed in the column editor. Keep in mind that Oracle treats NULL as an empty string when concatenating ('a' || NULL is 'a'), while PostgreSQL returns NULL. The Migrator translates concatenations of virtual columns accordingly, e.g. first_name || ' ' || last_name becomes nullif(coalesce((first_name)::text, '') || ' ' || coalesce((last_name)::text, ''), ''). Functions such as concat() can not be used, as generated columns only allow immutable expressions.

Command line

The validate command of the core validates the data on the command line and shows the progress in the terminal:

cli validate 4cb2f68b-41b1-49ef-a086-aa9255f57677
cli validate 4cb2f68b-41b1-49ef-a086-aa9255f57677 --mode row_count --format json > validation.json
OptionDescription
--mode <mode>full (default) or row_count
--snapshot <snapshot>migration (default, the SCN of the data stage) or current
--table <fqn...>validate only these tables, e.g. table:"HR"."EMPLOYEES"
--format <format>text (default) or json

Press Ctrl+C to cancel. The exit code is 0 if all tables match, 2 if differences were found or the validation did not finish, and 1 on errors. The result is stored, so it is shown in the Data Validation tab as well.

REST API

EndpointDescription
POST /migrations/{migration_id}/validationstart a validation with {"mode": "full"} or {"mode": "row_count"}, optionally snapshot and tables
GET /migrations/{migration_id}/validationthe latest validation including its progress
DELETE /migrations/{migration_id}/validationcancel the running validation

Privileges

The Oracle user of the migration needs the privileges of the data stage: SELECT and FLASHBACK on the migrated tables (or SELECT ANY TABLE and FLASHBACK ANY TABLE). EXECUTE on SYS.DBMS_CRYPTO is optional and enables the comparison of the complete content of large objects.