tech on the net
Home About Us Feedback Site Map

Microsoft

Access Excel Word

Database

SQL Oracle / PLSQL SQL Server MySQL MariaDB PostgreSQL

Web Development

HTML CSS Color Picker

Language

C Language

More

ASCII Table Linux UNIX Java Clipart Joke of the Moment

Other Sites

CheckYourMath BigActivities DigMinecraft
Share this page:

Oracle/PLSQL: CAST Function

Learn how to use the Oracle/PLSQL CAST function with syntax and examples.

Description

The Oracle/PLSQL CAST function converts one datatype to another.

Syntax

The syntax for the Oracle/PLSQL CAST function is:

CAST ( { expr | ( subquery ) | MULTISET ( subquery ) } AS type_name )

Note

The following casts are allowed:

TO FROM
char, varchar2 number datetime / interval raw rowid, urowid nchar, nvarchar2
char, varchar2 X X X X X  
number X X        
datetime / interval X   X      
raw X     X    
rowid, urowid X       X  
nchar, nvarchar2   X X X X X

Applies To

The CAST function can be used in the following versions of Oracle/PLSQL:

  • Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i

Example

Let's look at some Oracle CAST function examples and explore how to use the CAST function in Oracle/PLSQL.

For example:

select CAST( '22-Aug-2003' AS varchar2(30) )
from dual;

This would convert the date (ie: 22-Aug-2003) into a varchar2(30) value.