Refer my part-1 if you miss it. In my next example, I will give converting CHAR column to VARCHAR
CAST(CHAR-CLMN as VARCHAR(100));
In the second way, CREATE DISTINCT TYPE SAL_1 AS DECIMAL(9,2); This is equal to CAST function.
CAST(SAL_1 AS DECIMAL(9,2));
Points to Remember
- The function CAST helps you to change almost all data types into another data types.
- Before casting we need to make sure that you understand the rules
- Converting type may have an impact on the result
- Few people asked that unable to convert INTEGER to STRING. Before doing read all the CAST function rules.
Refer here on possibility of data types and rules for CAST.