How to resolve ORA-01790 Error Message in Oracle database

Learn the cause and how to unravel the ORA-01790 error message in Oracle.


When you stumble upon an ORA-01790 error, the following error message will appear:

ORA-01790: expression have to have identical datatype as corresponding expression


You tried to execute a SELECT announcement (probably a UNION query or a UNION ALL query), and all of the queries did not include matching information sorts in the end result columns.


The option(s) to resolve this Oracle error are:

Option #1

Re-write the SELECT assertion so that every matching column is the equal data type.

For example, if you tried to execute the following UNION query:

SELECT supplier_name
FROM orders
SELECT quantity
FROM orders_audit;

You would receive an error message as follows:

Since the supplier_name column is described as a varchar2 and the quantity column is described as a number, these columns can no longer be matching columns.

You can strive correcting this UNION query via using a conversion function (ie: TO_CHAR function, TO_NUMBER function, or TO_DATE function) to convert the values to matching records types.

For example:

SELECT supplier_name
FROM orders
SELECT TO_CHAR(quantity)
FROM orders_audit;

In this example, we have used the TO_CHAR function to convert the quantity column to a data kind that is well suited with the supplier_name column.