Skip to content

CAST

  • expression: The value that is intended to be converted into a different data type. This can be a table column, a variable, a constant, or a function that the SQL engine interprets as a value.
  • type: The data type that the expression is to be converted into. It could be a number of different types including INTEGER, VARCHAR, DATE etc. depending on the needs of the query.
SELECT CAST(123 AS CHAR);
'123'

The CAST function is used to convert a value from one data type to another. In the given example, the integer value 123 is converted to a string value '123'.