sqlÖÐÌåÏÖÒ»¸ö×Ö·ûµÄº¯Êý
sql ÖÐÌåÏÖµ¥¸ö×Ö·ûµÄº¯ÊýÓУºsubstring£ºÌáÈ¡Ö¸¶¨Î»ÖõÄ×Ó×Ö·û´®£¨ÌṩÆðʼλÖúͳ¤¶ÈΪ 1£©char£º½¨Éè unicode ×Ö·û£¨½ÓÊÜ unicode ´úÂëµã£©chr£º½¨Éè ascii ×Ö·û£¨½ÓÊÜ ascii ´úÂëµã£©unichar£º½¨Éè unicode ×Ö·û£¨½ÓÊÜ×Ö·ûÃû³Æ£©
SQL ÖÐÌåÏÖÒ»¸ö×Ö·ûµÄº¯Êý
SQL ÖÐÓм¸¸öº¯Êý¿ÉÒÔ×ÊÖú»ñÈ¡»òÌåÏÖµ¥¸ö×Ö·û£º
1. SUBSTRING º¯Êý
SUBSTRING º¯ÊýÌáÈ¡×Ö·û´®Ö¸¶¨Î»ÖõÄ×Ó×Ö·û´®¡£ÈôÒª»ñÈ¡µ¥¸ö×Ö·û£¬ÇëÌṩÆðʼλÖúͳ¤¶ÈΪ 1¡£
Óï·¨£ºSUBSTRING(string, start_position, length)
ʾÀý£º»ñÈ¡×Ö·û´® “Hello” ÖеĵÚÒ»¸ö×Ö·û£º
SELECT SUBSTRING('Hello', 1, 1); -- Êä³ö£ºH
µÇ¼ºó¸´ÖÆ
2. CHAR º¯Êý
CHAR º¯Êý´Ó Unicode ×Ö·û¼¯½¨Éèµ¥¸ö×Ö·û¡£Ëü½ÓÊÜÒ»¸öÕûÊýÖµ×÷Ϊ²ÎÊý£¬¸ÃÕûÊýÖµÌåÏÖ Unicode ×Ö·ûµÄ´úÂëµã¡£
Óï·¨£ºCHAR(character_code)
ʾÀý£º»ñÈ¡ Unicode ×Ö·û “A”£¨´úÂëµãΪ 65£©£º
SELECT CHAR(65); -- Êä³ö£ºA
µÇ¼ºó¸´ÖÆ
3. CHR º¯Êý
CHR º¯ÊýÓë CHAR º¯ÊýÀàËÆ£¬µ«Ëü½ÓÊÜ ASCII ×Ö·ûÂë×÷Ϊ²ÎÊý¡£
Óï·¨£ºCHR(character_code)
ʾÀý£º»ñÈ¡ ASCII ×Ö·û “A”£¨´úÂëµãΪ 65£©£º
SELECT CHR(65); -- Êä³ö£ºA
µÇ¼ºó¸´ÖÆ
4. UNICHAR º¯Êý
UNICHAR º¯Êý´Ó Unicode ×Ö·û¼¯Öн¨Éèµ¥¸ö×Ö·û¡£Ëü½ÓÊÜÒ»¸ö×Ö·û´®²ÎÊý£¬¸Ã²ÎÊýÖ¸¶¨ÒªÌåÏÖµÄ×Ö·ûµÄÃû³Æ¡£
Óï·¨£ºUNICHAR(character_name)
ʾÀý£º»ñÈ¡ Unicode ×Ö·û “ÐǺŔ£¨Ãû³ÆΪ “*£©£º
SELECT UNICHAR('*'); -- Êä³ö£º*
µÇ¼ºó¸´ÖÆ
ÒÔÉϾÍÊÇsqlÖÐÌåÏÖÒ»¸ö×Ö·ûµÄº¯ÊýµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡