Chapter 3: Selecting
Chapter 3: Selecting
Function Description
TRIM ( p ) Returns string p with leading and trailing spaces
removed.
UPPER ( p ) Returns string p converted to uppercase.
The CAST function performs a conversion from one data type to another. For
example, CAST ( '123' AS INTEGER ) converts the string '123' into an
INTEGER 123.
CAST will fail if there is an obvious data conversion error, but it also has
some subtle limitations. For example, CAST ( 123.456 AS INTEGER ) works
just fine to truncate 123.456 and return 123, but CAST ( '123.456' AS
INTEGER ) will fail; you have to do that conversion in two steps: CAST
( CAST ( '123.456' AS NUMERIC ) AS INTEGER ).
Nevertheless, CAST is very useful. Heres another example to show its
flexibility:
CREATE TABLE t1 (
key_1 UNSIGNED BIGINT NOT NULL,
non_key_1 VARCHAR ( 100 ) NOT NULL,
last_updated TIMESTAMP NOT NULL,
PRIMARY KEY ( key_1 ) );