Convert one datatype to other in oracle using CAST function

By Santhosh N

This explains how to convert one datatype to other in oracle.

There is a conversion function in oracle by the name, CAST which converts one datatype to other in oracle.
However, the target type needs to be a convertible type like integer can be converted to string type but vice versa is not always possible.
For example,  if string has chars and wanted to convert that to integer, it throws exception.

Syntax: CAST({expression | subQuery | MultiSet(subquery)} as dataTypeName)

Here expression is the value that needs to be converted and dataTypeName is the type that needs to be converted to.

Ex1: SELECT CAST(’10-06-2010’ AS varchar2(40)) FROM dual;
This converts the date to varchar2 type

Related FAQs

This explains how to convert the string to an interval Year to Month type in oracle.
This explains how to convert LOB value to NCLOB value in oracle.
This explains how to convert LOB value from the national character set to the Database character set.
This explains how to convert a hexadecimal value into a raw value in oracle.
This explains how to convert the both single-byte and multi-byte characters in oracle string to multi-byte characters.
This explains how to convert a string value to the timestamp with time zone value in oracle.
Convert one datatype to other in oracle using CAST function  (2089 Views)