oracleÖÐ×Ö·û´®ÀàÐ͵ÄÊý×ÖÔõôÅÌËã
ÔÚ oracle ÖУ¬×Ö·û´®ÀàÐ͵ÄÊý×Ö¿ÉÒÔͨ¹ý cast »ò to_number º¯Êýת»»ÎªÊý×Ö£¬Ö®ºó¼´¿É¾ÙÐÐÊýѧÔËË㡣ת»»Ê±Ðè×¢ÖØÈ·±£ËùÓÐ×Ö·û´®¶¼ÒÑת»»ÎªÊý×Ö£¬ÒÔ×èÖ¹¹ýʧ¡£oracle Ò²ÌṩÆäËûº¯Êý£¨Èç substr ºÍ instr£©À´²Ù×÷×Ö·û´®ÀàÐ͵ÄÊý×Ö¡£
ÔõÑùÔÚ Oracle ÖжÔ×Ö·û´®ÀàÐ͵ÄÊý×Ö¾ÙÐÐÅÌËã
Oracle Êý¾Ý¿âÖеÄ×Ö·û´®ÀàÐÍ¿ÉÒÔ´æ´¢Êý×ÖÖµ¡£¿ÉÊÇ£¬ÔÚ¾ÙÐÐÊýѧÔËËãʱ£¬ÕâЩ×Ö·û´®ÐèҪת»»ÎªÊý×ÖÀàÐÍ¡£
ת»»×Ö·û´®µ½Êý×Ö
ÓÐÁ½ÖÖÒªÁì¿ÉÒÔ½«×Ö·û´®×ª»»ÎªÊý×Ö£º
CAST º¯Êý£ºÀýÈ磬CAST(‘123’ AS NUMBER) ½«×Ö·û´® “123” ת»»ÎªÊý×Ö 123¡£
TO_NUMBER º¯Êý£ºÀýÈ磬TO_NUMBER(‘123’) Ò²¿ÉÒÔ½«×Ö·û´® “123” ת»»ÎªÊý×Ö 123¡£
¾ÙÐÐÊýѧÔËËã
Ò»µ©×Ö·û´®×ª»»ÎªÊý×Ö£¬¾Í¿ÉÒÔ¶ÔËüÃǾÙÐÐÊýѧÔËË㣬¾ÍÏñ¶ÔͨË×Êý×ÖÒ»Ñù¡£ÀýÈ磺
SELECT 10 + ‘123’ FROM DUAL; ½«·µ»Ø 133¡£
SELECT 10 * TO_NUMBER(‘123’) FROM DUAL; Ò²½«·µ»Ø 133¡£
×¢ÖØ£º
ÔÚ¾ÙÐÐÊýѧÔËËã֮ǰ£¬ÇëÈ·±£ËùÓÐ×Ö·û´®¶¼ÒÑת»»ÎªÊý×Ö¡£
ÈôÊÇ×Ö·û´®°üÀ¨·ÇÊý×Ö×Ö·û£¬Ôòת»»½«Ê§°Ü£¬²¢¿ÉÄܵ¼Ö¹ýʧ¡£
Oracle Ò²ÌṩÁËһЩÄÚÖú¯ÊýÀ´²Ù×÷×Ö·û´®ÀàÐ͵ÄÊý×Ö£¬ÀýÈç SUBSTR ºÍ INSTR¡£
ÒÔÉϾÍÊÇoracleÖÐ×Ö·û´®ÀàÐ͵ÄÊý×ÖÔõôÅÌËãµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡