Ïðåîáðàçîâàíèå òèïîâ (CAST)
 SQL èìååòñÿ âîçìîæíîñòü ïðåîáðàçîâàòü çíà÷åíèå ñòîëáöà èëè ôóíêöèè ê äðóãîìó òèïó äëÿ áîëåå ãèáêîãî èñïîëüçîâàíèÿ îïåðàöèé ñðàâíåíèÿ. Äëÿ ýòîãî èñïîëüçóåòñÿ ôóíêöèÿ CAST.
Òèïû äàííûõ ìîãóò áûòü êîíâåðòèðîâàíû â ñîîòâåòñòâèè ñî ñëåäóþùåé òàáëèöåé:
Èç òèïà äàííûõ Â òèï äàííûõ
---------------------------------------
NUMERIC CHAR, VARCHAR, DATE
CHAR, VARCHAR NUMERIC, DATE
DATE CHAR, VARCHAR, DATE
SELECT first_name, last_name, dept_no
FROM employee
WHERE CAST(dept_no AS char(20))
CONTAINING "00" ïîëó÷èòü ñïèñîê ñîòðóäíèêîâ,
çàíÿòûõ â îòäåëàõ,
íîìåðà êîòîðûõ ñîäåðæàò “00”
FIRST_NAME LAST_NAME DEPT_NO
=============== ==================== =======
Robert Nelson 600
Terri Lee 000
Stewart Hall 900
Walter Steadman 900
Mary S. MacDonald 100
Oliver H. Bender 000
Kelly Brown 600
Michael Yanowski 100