Converting Data Types with CAST()

In many situations, your DBMS will convert, or cast, data types automatically. It may allow you to use numbers and dates in character expressions such as concatenation, for example, or it will promote numbers automatically in mixed arithmetic expressions (see the DBMS Tip in “Performing Arithmetic Operations” earlier in this chapter). Use the CAST() function to convert an expression of one data type to another data type when your DBMS doesn’t perform the conversion automatically. For information about data types, see “Data Types” in Chapter 3.

The CAST() function’s important characteristics are:

  • Implicit conversions are those conversions that occur without specifying CAST(). Explicit conversions are those conversions ...

Get SQL: Visual QuickStart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.