{"id":24640,"date":"2025-04-19T10:29:11","date_gmt":"2025-04-19T02:29:11","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/24640.html"},"modified":"2025-04-19T10:29:11","modified_gmt":"2025-04-19T02:29:11","slug":"hive-sql-%e7%b2%be%e8%bf%9b%e7%b3%bb%e5%88%97%ef%bc%9asubstr-%e5%87%bd%e6%95%b0%e7%9a%84%e5%a4%9a%e6%a0%b7%e7%94%a8%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/24640.html","title":{"rendered":"Hive SQL \u7cbe\u8fdb\u7cfb\u5217\uff1aSUBSTR \u51fd\u6570\u7684\u591a\u6837\u7528\u6cd5"},"content":{"rendered":"<h3><\/h3>\n<hr \/>\n<h4>\u76ee\u5f55<\/h4>\n<ul>\n<li>\n<ul>\n<li><\/li>\n<li>\u4e00\u3001\u5f15\u8a00<\/li>\n<li>\u4e8c\u3001SUBSTR \u51fd\u6570\u57fa\u7840\u4ecb\u7ecd<\/li>\n<li>\n<ul>\n<li>2.1 \u57fa\u672c\u8bed\u6cd5<\/li>\n<li>2.2 \u53c2\u6570\u8be6\u89e3<\/li>\n<li>2.3 \u7b80\u5355\u793a\u4f8b<\/li>\n<\/ul>\n<\/li>\n<li>\u4e09\u3001SUBSTR \u51fd\u6570\u5e38\u89c1\u5e94\u7528\u573a\u666f<\/li>\n<li>\n<ul>\n<li>3.1 \u63d0\u53d6\u65e5\u671f\u4e2d\u7684\u5e74\u4efd\u3001\u6708\u4efd\u6216\u65e5\u671f<\/li>\n<li>3.2 \u9690\u85cf\u90e8\u5206\u654f\u611f\u4fe1\u606f<\/li>\n<\/ul>\n<\/li>\n<li>\u56db\u3001SUBSTR \u51fd\u6570\u9ad8\u7ea7\u7528\u6cd5<\/li>\n<li>\n<ul>\n<li>4.1 \u7ed3\u5408\u6761\u4ef6\u5224\u65ad\u52a8\u6001\u622a\u53d6<\/li>\n<li>4.2 \u5904\u7406\u590d\u6742\u5b57\u7b26\u4e32\u6a21\u5f0f<\/li>\n<\/ul>\n<\/li>\n<li>\u4e94\u3001\u603b\u7ed3<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>\u4e00\u3001\u5f15\u8a00<\/h3>\n<p>SUBSTR \u51fd\u6570\u662f Hive SQL \u4e2d\u4e00\u4e2a\u7528\u4e8e\u5b57\u7b26\u4e32\u622a\u53d6\u7684\u91cd\u8981\u51fd\u6570&#xff0c;\u5728\u5904\u7406\u6587\u672c\u6570\u636e\u65f6\u53d1\u6325\u7740\u5173\u952e\u4f5c\u7528\u3002\u672c\u6587\u5c06\u5168\u9762\u4e14\u6df1\u5165\u5730\u4ecb\u7ecd Hive SQL \u4e2d SUBSTR \u51fd\u6570\u7684\u57fa\u672c\u8bed\u6cd5\u3001\u5e38\u89c1\u5e94\u7528\u573a\u666f\u4ee5\u53ca\u4e00\u4e9b\u9ad8\u7ea7\u7528\u6cd5\u3002<\/p>\n<h3>\u4e8c\u3001SUBSTR \u51fd\u6570\u57fa\u7840\u4ecb\u7ecd<\/h3>\n<h4>2.1 \u57fa\u672c\u8bed\u6cd5<\/h4>\n<p>SUBSTR \u51fd\u6570\u4e3b\u8981\u7528\u4e8e\u4ece\u5b57\u7b26\u4e32\u4e2d\u63d0\u53d6\u6307\u5b9a\u4f4d\u7f6e\u548c\u957f\u5ea6\u7684\u5b50\u5b57\u7b26\u4e32\u3002\u5b83\u6709\u4e24\u79cd\u5e38\u89c1\u7684\u8bed\u6cd5\u5f62\u5f0f&#xff1a;<\/p>\n<p><span class=\"token comment\">&#8212; \u5f62\u5f0f\u4e00&#xff1a;\u6307\u5b9a\u8d77\u59cb\u4f4d\u7f6e\u548c\u622a\u53d6\u957f\u5ea6<\/span><br \/>\nSUBSTR<span class=\"token punctuation\">(<\/span>str<span class=\"token punctuation\">,<\/span> pos<span class=\"token punctuation\">,<\/span> len<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\">&#8212; \u5f62\u5f0f\u4e8c&#xff1a;\u53ea\u6307\u5b9a\u8d77\u59cb\u4f4d\u7f6e&#xff0c;\u622a\u53d6\u4ece\u8d77\u59cb\u4f4d\u7f6e\u5230\u5b57\u7b26\u4e32\u672b\u5c3e\u7684\u6240\u6709\u5b57\u7b26<\/span><br \/>\nSUBSTR<span class=\"token punctuation\">(<\/span>str<span class=\"token punctuation\">,<\/span> pos<span class=\"token punctuation\">)<\/span><\/p>\n<h4>2.2 \u53c2\u6570\u8be6\u89e3<\/h4>\n<ul>\n<li>str&#xff1a;\u8fd9\u662f\u8981\u8fdb\u884c\u622a\u53d6\u64cd\u4f5c\u7684\u539f\u59cb\u5b57\u7b26\u4e32\u3002\u5b83\u53ef\u4ee5\u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\u5e38\u91cf&#xff0c;\u4e5f\u53ef\u4ee5\u662f\u8868\u4e2d\u7684\u67d0\u4e2a\u5b57\u7b26\u4e32\u7c7b\u578b\u7684\u5b57\u6bb5\u3002<\/li>\n<li>pos&#xff1a;\u8868\u793a\u622a\u53d6\u7684\u8d77\u59cb\u4f4d\u7f6e\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f&#xff0c;\u5728 Hive SQL \u4e2d&#xff0c;\u5b57\u7b26\u4e32\u7684\u7d22\u5f15\u662f\u4ece 1 \u5f00\u59cb\u7684\u3002\u5982\u679c pos \u4e3a\u6b63\u6570&#xff0c;\u90a3\u4e48\u622a\u53d6\u5c06\u4ece\u5b57\u7b26\u4e32\u7684\u5de6\u8fb9\u5f00\u59cb\u8ba1\u6570&#xff1b;\u5982\u679c pos \u4e3a\u8d1f\u6570&#xff0c;\u622a\u53d6\u5c06\u4ece\u5b57\u7b26\u4e32\u7684\u53f3\u8fb9\u5f00\u59cb\u8ba1\u6570\u3002<\/li>\n<li>len&#xff1a;\u8fd9\u662f\u4e00\u4e2a\u53ef\u9009\u53c2\u6570&#xff0c;\u7528\u4e8e\u6307\u5b9a\u8981\u622a\u53d6\u7684\u5b50\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\u3002\u5982\u679c\u7701\u7565\u8be5\u53c2\u6570&#xff0c;\u5219\u9ed8\u8ba4\u622a\u53d6\u4ece\u8d77\u59cb\u4f4d\u7f6e\u5230\u5b57\u7b26\u4e32\u672b\u5c3e\u7684\u6240\u6709\u5b57\u7b26\u3002<\/li>\n<\/ul>\n<h4>2.3 \u7b80\u5355\u793a\u4f8b<\/h4>\n<p>\u4e3a\u4e86\u66f4\u597d\u5730\u7406\u89e3 SUBSTR \u51fd\u6570\u7684\u57fa\u672c\u7528\u6cd5&#xff0c;\u6211\u4eec\u5148\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u8868\u5e76\u63d2\u5165\u4e00\u4e9b\u6570\u636e&#xff1a;<\/p>\n<p><span class=\"token comment\">&#8212; \u521b\u5efa\u793a\u4f8b\u8868<\/span><br \/>\n<span class=\"token keyword\">CREATE<\/span> <span class=\"token keyword\">TABLE<\/span> text_data <span class=\"token punctuation\">(<\/span><br \/>\n    id <span class=\"token keyword\">INT<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    full_name STRING<br \/>\n<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; \u63d2\u5165\u793a\u4f8b\u6570\u636e<\/span><br \/>\n<span class=\"token keyword\">INSERT<\/span> <span class=\"token keyword\">INTO<\/span> text_data <span class=\"token keyword\">VALUES<\/span><br \/>\n<span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;John Doe&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n<span class=\"token punctuation\">(<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;Jane Smith&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n<span class=\"token punctuation\">(<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;Bob Johnson&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u73b0\u5728&#xff0c;\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 SUBSTR \u51fd\u6570\u6765\u622a\u53d6 full_name \u5b57\u6bb5\u4e2d\u7684\u59d3\u6c0f\u3002\u5047\u8bbe\u59d3\u6c0f\u662f\u540d\u5b57\u4e2d\u7684\u6700\u540e\u4e00\u4e2a\u5355\u8bcd&#xff0c;\u6211\u4eec\u53ef\u4ee5\u4ece\u5012\u6570\u7b2c\u4e00\u4e2a\u7a7a\u683c\u4e4b\u540e\u5f00\u59cb\u622a\u53d6&#xff1a;<\/p>\n<p><span class=\"token comment\">&#8212; \u622a\u53d6\u59d3\u6c0f<\/span><br \/>\n<span class=\"token keyword\">SELECT<\/span><br \/>\n    id<span class=\"token punctuation\">,<\/span><br \/>\n    full_name<span class=\"token punctuation\">,<\/span><br \/>\n    SUBSTR<span class=\"token punctuation\">(<\/span>full_name<span class=\"token punctuation\">,<\/span> INSTR<span class=\"token punctuation\">(<\/span>full_name<span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039; &#039;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#043;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">AS<\/span> last_name<br \/>\n<span class=\"token keyword\">FROM<\/span><br \/>\n    text_data<span class=\"token punctuation\">;<\/span><\/p>\n<p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d&#xff0c;INSTR(full_name, &#039; &#039;) \u7528\u4e8e\u67e5\u627e\u5b57\u7b26\u4e32\u4e2d\u7b2c\u4e00\u4e2a\u7a7a\u683c\u7684\u4f4d\u7f6e&#xff0c;\u7136\u540e SUBSTR \u51fd\u6570\u4ece\u8be5\u4f4d\u7f6e\u7684\u4e0b\u4e00\u4e2a\u5b57\u7b26\u5f00\u59cb\u622a\u53d6&#xff0c;\u76f4\u5230\u5b57\u7b26\u4e32\u672b\u5c3e&#xff0c;\u4ece\u800c\u5f97\u5230\u59d3\u6c0f\u3002\u8fd0\u884c\u8be5\u67e5\u8be2\u540e&#xff0c;\u6211\u4eec\u5c06\u5f97\u5230\u5982\u4e0b\u7ed3\u679c&#xff1a;<\/p>\n<table>\n<tr>idfull_namelast_name<\/tr>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>John Doe<\/td>\n<td>Doe<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>Jane Smith<\/td>\n<td>Smith<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>Bob Johnson<\/td>\n<td>Johnson<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u4e09\u3001SUBSTR \u51fd\u6570\u5e38\u89c1\u5e94\u7528\u573a\u666f<\/h3>\n<h4>3.1 \u63d0\u53d6\u65e5\u671f\u4e2d\u7684\u5e74\u4efd\u3001\u6708\u4efd\u6216\u65e5\u671f<\/h4>\n<p>\u5728\u5904\u7406\u65e5\u671f\u6570\u636e\u65f6&#xff0c;\u7ecf\u5e38\u9700\u8981\u4ece\u65e5\u671f\u5b57\u7b26\u4e32\u4e2d\u63d0\u53d6\u5e74\u4efd\u3001\u6708\u4efd\u6216\u65e5\u671f\u3002\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u5305\u542b\u65e5\u671f\u4fe1\u606f\u7684\u8868 date_table&#xff0c;\u65e5\u671f\u683c\u5f0f\u4e3a YYYY-MM-DD&#xff1a;<\/p>\n<p><span class=\"token comment\">&#8212; \u521b\u5efa\u65e5\u671f\u8868<\/span><br \/>\n<span class=\"token keyword\">CREATE<\/span> <span class=\"token keyword\">TABLE<\/span> date_table <span class=\"token punctuation\">(<\/span><br \/>\n    record_id <span class=\"token keyword\">INT<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    date_str STRING<br \/>\n<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; \u63d2\u5165\u793a\u4f8b\u6570\u636e<\/span><br \/>\n<span class=\"token keyword\">INSERT<\/span> <span class=\"token keyword\">INTO<\/span> date_table <span class=\"token keyword\">VALUES<\/span><br \/>\n<span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;2024-05-15&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n<span class=\"token punctuation\">(<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;2025-03-20&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n<span class=\"token punctuation\">(<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;2026-07-10&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; \u63d0\u53d6\u5e74\u4efd<\/span><br \/>\n<span class=\"token keyword\">SELECT<\/span><br \/>\n    record_id<span class=\"token punctuation\">,<\/span><br \/>\n    date_str<span class=\"token punctuation\">,<\/span><br \/>\n    SUBSTR<span class=\"token punctuation\">(<\/span>date_str<span class=\"token punctuation\">,<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">4<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">AS<\/span> <span class=\"token keyword\">year<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    SUBSTR<span class=\"token punctuation\">(<\/span>date_str<span class=\"token punctuation\">,<\/span> <span class=\"token number\">6<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">AS<\/span> <span class=\"token keyword\">month<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    SUBSTR<span class=\"token punctuation\">(<\/span>date_str<span class=\"token punctuation\">,<\/span> <span class=\"token number\">9<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">AS<\/span> <span class=\"token keyword\">day<\/span><br \/>\n<span class=\"token keyword\">FROM<\/span><br \/>\n    date_table<span class=\"token punctuation\">;<\/span><\/p>\n<p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d&#xff0c;\u901a\u8fc7 SUBSTR \u51fd\u6570\u5206\u522b\u622a\u53d6\u65e5\u671f\u5b57\u7b26\u4e32\u7684\u4e0d\u540c\u90e8\u5206&#xff0c;\u4ece\u800c\u5f97\u5230\u5e74\u4efd\u3001\u6708\u4efd\u548c\u65e5\u671f\u3002\u8fd0\u884c\u8be5\u67e5\u8be2\u540e&#xff0c;\u7ed3\u679c\u5982\u4e0b&#xff1a;<\/p>\n<table>\n<tr>record_iddate_stryearmonthday<\/tr>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>2024-05-15<\/td>\n<td>2024<\/td>\n<td>05<\/td>\n<td>15<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>2025-03-20<\/td>\n<td>2025<\/td>\n<td>03<\/td>\n<td>20<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>2026-07-10<\/td>\n<td>2026<\/td>\n<td>07<\/td>\n<td>10<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>3.2 \u9690\u85cf\u90e8\u5206\u654f\u611f\u4fe1\u606f<\/h4>\n<p>\u5728\u5904\u7406\u5305\u542b\u654f\u611f\u4fe1\u606f\u7684\u6570\u636e\u65f6&#xff0c;\u4e3a\u4e86\u4fdd\u62a4\u6570\u636e\u5b89\u5168&#xff0c;\u6211\u4eec\u53ef\u80fd\u9700\u8981\u9690\u85cf\u90e8\u5206\u4fe1\u606f\u3002\u4f8b\u5982&#xff0c;\u9690\u85cf\u624b\u673a\u53f7\u7801\u7684\u4e2d\u95f4\u51e0\u4f4d&#xff1a;<\/p>\n<p><span class=\"token comment\">&#8212; \u521b\u5efa\u5305\u542b\u624b\u673a\u53f7\u7801\u7684\u8868<\/span><br \/>\n<span class=\"token keyword\">CREATE<\/span> <span class=\"token keyword\">TABLE<\/span> phone_numbers <span class=\"token punctuation\">(<\/span><br \/>\n    user_id <span class=\"token keyword\">INT<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    phone_number STRING<br \/>\n<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; \u63d2\u5165\u793a\u4f8b\u6570\u636e<\/span><br \/>\n<span class=\"token keyword\">INSERT<\/span> <span class=\"token keyword\">INTO<\/span> phone_numbers <span class=\"token keyword\">VALUES<\/span><br \/>\n<span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;13800138000&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n<span class=\"token punctuation\">(<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;13900139000&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n<span class=\"token punctuation\">(<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;15000150000&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; \u9690\u85cf\u624b\u673a\u53f7\u7801\u4e2d\u95f4\u56db\u4f4d<\/span><br \/>\n<span class=\"token keyword\">SELECT<\/span><br \/>\n    user_id<span class=\"token punctuation\">,<\/span><br \/>\n    CONCAT<span class=\"token punctuation\">(<\/span>SUBSTR<span class=\"token punctuation\">(<\/span>phone_number<span class=\"token punctuation\">,<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">3<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;****&#039;<\/span><span class=\"token punctuation\">,<\/span> SUBSTR<span class=\"token punctuation\">(<\/span>phone_number<span class=\"token punctuation\">,<\/span> <span class=\"token number\">8<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">AS<\/span> masked_phone<br \/>\n<span class=\"token keyword\">FROM<\/span><br \/>\n    phone_numbers<span class=\"token punctuation\">;<\/span><\/p>\n<p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d&#xff0c;\u9996\u5148\u4f7f\u7528 SUBSTR \u51fd\u6570\u622a\u53d6\u624b\u673a\u53f7\u7801\u7684\u524d\u4e09\u4f4d\u548c\u540e\u56db\u4f4d&#xff0c;\u7136\u540e\u4f7f\u7528 CONCAT \u51fd\u6570\u5c06\u5b83\u4eec\u4e0e **** \u62fc\u63a5\u8d77\u6765&#xff0c;\u4ece\u800c\u5b9e\u73b0\u9690\u85cf\u4e2d\u95f4\u56db\u4f4d\u7684\u6548\u679c\u3002\u8fd0\u884c\u8be5\u67e5\u8be2\u540e&#xff0c;\u7ed3\u679c\u5982\u4e0b&#xff1a;<\/p>\n<table>\n<tr>user_idmasked_phone<\/tr>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>138****8000<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>139****9000<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>150****0000<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u56db\u3001SUBSTR \u51fd\u6570\u9ad8\u7ea7\u7528\u6cd5<\/h3>\n<h4>4.1 \u7ed3\u5408\u6761\u4ef6\u5224\u65ad\u52a8\u6001\u622a\u53d6<\/h4>\n<p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d&#xff0c;\u6211\u4eec\u53ef\u80fd\u9700\u8981\u6839\u636e\u4e0d\u540c\u7684\u6761\u4ef6\u52a8\u6001\u5730\u8fdb\u884c\u5b57\u7b26\u4e32\u622a\u53d6\u3002\u4f8b\u5982&#xff0c;\u5bf9\u4e8e\u4e0d\u540c\u957f\u5ea6\u7684\u5b57\u7b26\u4e32&#xff0c;\u91c7\u7528\u4e0d\u540c\u7684\u622a\u53d6\u7b56\u7565&#xff1a;<\/p>\n<p><span class=\"token comment\">&#8212; \u521b\u5efa\u5305\u542b\u4e0d\u540c\u957f\u5ea6\u5b57\u7b26\u4e32\u7684\u8868<\/span><br \/>\n<span class=\"token keyword\">CREATE<\/span> <span class=\"token keyword\">TABLE<\/span> variable_length_text <span class=\"token punctuation\">(<\/span><br \/>\n    text_id <span class=\"token keyword\">INT<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    text_content STRING<br \/>\n<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; \u63d2\u5165\u793a\u4f8b\u6570\u636e<\/span><br \/>\n<span class=\"token keyword\">INSERT<\/span> <span class=\"token keyword\">INTO<\/span> variable_length_text <span class=\"token keyword\">VALUES<\/span><br \/>\n<span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;Short text&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n<span class=\"token punctuation\">(<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;This is a much longer text&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n<span class=\"token punctuation\">(<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;A medium length text&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; \u6839\u636e\u5b57\u7b26\u4e32\u957f\u5ea6\u52a8\u6001\u622a\u53d6<\/span><br \/>\n<span class=\"token keyword\">SELECT<\/span><br \/>\n    text_id<span class=\"token punctuation\">,<\/span><br \/>\n    text_content<span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token keyword\">CASE<\/span><br \/>\n        <span class=\"token keyword\">WHEN<\/span> LENGTH<span class=\"token punctuation\">(<\/span>text_content<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&lt;&#061;<\/span> <span class=\"token number\">10<\/span> <span class=\"token keyword\">THEN<\/span> text_content<br \/>\n        <span class=\"token keyword\">WHEN<\/span> LENGTH<span class=\"token punctuation\">(<\/span>text_content<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&lt;&#061;<\/span> <span class=\"token number\">20<\/span> <span class=\"token keyword\">THEN<\/span> SUBSTR<span class=\"token punctuation\">(<\/span>text_content<span class=\"token punctuation\">,<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">10<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token keyword\">ELSE<\/span> SUBSTR<span class=\"token punctuation\">(<\/span>text_content<span class=\"token punctuation\">,<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">15<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">END<\/span> <span class=\"token keyword\">AS<\/span> truncated_text<br \/>\n<span class=\"token keyword\">FROM<\/span><br \/>\n    variable_length_text<span class=\"token punctuation\">;<\/span><\/p>\n<p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d&#xff0c;\u4f7f\u7528 CASE \u8bed\u53e5\u7ed3\u5408 LENGTH \u51fd\u6570\u6839\u636e\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\u8fdb\u884c\u5224\u65ad&#xff0c;\u7136\u540e\u4f7f\u7528 SUBSTR \u51fd\u6570\u8fdb\u884c\u4e0d\u540c\u957f\u5ea6\u7684\u622a\u53d6\u3002\u8fd0\u884c\u8be5\u67e5\u8be2\u540e&#xff0c;\u7ed3\u679c\u5982\u4e0b&#xff1a;<\/p>\n<table>\n<tr>text_idtext_contenttruncated_text<\/tr>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>Short text<\/td>\n<td>Short text<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>This is a much longer text<\/td>\n<td>This is a much<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>A medium length text<\/td>\n<td>A medium length<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>4.2 \u5904\u7406\u590d\u6742\u5b57\u7b26\u4e32\u6a21\u5f0f<\/h4>\n<p>\u5f53\u5b57\u7b26\u4e32\u4e2d\u5b58\u5728\u590d\u6742\u7684\u6a21\u5f0f\u65f6&#xff0c;SUBSTR \u51fd\u6570\u53ef\u4ee5\u4e0e\u5176\u4ed6\u5b57\u7b26\u4e32\u51fd\u6570\u7ed3\u5408\u4f7f\u7528\u6765\u63d0\u53d6\u6240\u9700\u4fe1\u606f\u3002\u4f8b\u5982&#xff0c;\u4ece\u5305\u542b\u7248\u672c\u53f7\u7684\u5b57\u7b26\u4e32\u4e2d\u63d0\u53d6\u4e3b\u7248\u672c\u53f7\u548c\u6b21\u7248\u672c\u53f7&#xff1a;<\/p>\n<p><span class=\"token comment\">&#8212; \u521b\u5efa\u5305\u542b\u7248\u672c\u53f7\u7684\u8868<\/span><br \/>\n<span class=\"token keyword\">CREATE<\/span> <span class=\"token keyword\">TABLE<\/span> version_info <span class=\"token punctuation\">(<\/span><br \/>\n    app_id <span class=\"token keyword\">INT<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    version_str STRING<br \/>\n<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; \u63d2\u5165\u793a\u4f8b\u6570\u636e<\/span><br \/>\n<span class=\"token keyword\">INSERT<\/span> <span class=\"token keyword\">INTO<\/span> version_info <span class=\"token keyword\">VALUES<\/span><br \/>\n<span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;1.2.3&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n<span class=\"token punctuation\">(<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;2.0.1&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n<span class=\"token punctuation\">(<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;3.1.5&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; \u63d0\u53d6\u4e3b\u7248\u672c\u53f7\u548c\u6b21\u7248\u672c\u53f7<\/span><br \/>\n<span class=\"token keyword\">SELECT<\/span><br \/>\n    app_id<span class=\"token punctuation\">,<\/span><br \/>\n    version_str<span class=\"token punctuation\">,<\/span><br \/>\n    SUBSTR<span class=\"token punctuation\">(<\/span>version_str<span class=\"token punctuation\">,<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> INSTR<span class=\"token punctuation\">(<\/span>version_str<span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;.&#039;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#8211;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">AS<\/span> major_version<span class=\"token punctuation\">,<\/span><br \/>\n    SUBSTR<span class=\"token punctuation\">(<\/span>version_str<span class=\"token punctuation\">,<\/span> INSTR<span class=\"token punctuation\">(<\/span>version_str<span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;.&#039;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#043;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> INSTR<span class=\"token punctuation\">(<\/span>SUBSTR<span class=\"token punctuation\">(<\/span>version_str<span class=\"token punctuation\">,<\/span> INSTR<span class=\"token punctuation\">(<\/span>version_str<span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;.&#039;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#043;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;.&#039;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#8211;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">AS<\/span> minor_version<br \/>\n<span class=\"token keyword\">FROM<\/span><br \/>\n    version_info<span class=\"token punctuation\">;<\/span><\/p>\n<p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d&#xff0c;\u9996\u5148\u4f7f\u7528 INSTR \u51fd\u6570\u627e\u5230\u7b2c\u4e00\u4e2a . \u7684\u4f4d\u7f6e&#xff0c;\u7136\u540e\u4f7f\u7528 SUBSTR \u51fd\u6570\u622a\u53d6\u4e3b\u7248\u672c\u53f7\u3002\u5bf9\u4e8e\u6b21\u7248\u672c\u53f7&#xff0c;\u5148\u622a\u53d6\u7b2c\u4e00\u4e2a . \u4e4b\u540e\u7684\u5b57\u7b26\u4e32&#xff0c;\u518d\u4f7f\u7528 INSTR \u51fd\u6570\u627e\u5230\u65b0\u5b57\u7b26\u4e32\u4e2d . \u7684\u4f4d\u7f6e&#xff0c;\u6700\u540e\u4f7f\u7528 SUBSTR \u51fd\u6570\u622a\u53d6\u6b21\u7248\u672c\u53f7\u3002\u8fd0\u884c\u8be5\u67e5\u8be2\u540e&#xff0c;\u7ed3\u679c\u5982\u4e0b&#xff1a;<\/p>\n<table>\n<tr>app_idversion_strmajor_versionminor_version<\/tr>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>1.2.3<\/td>\n<td>1<\/td>\n<td>2<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>2.0.1<\/td>\n<td>2<\/td>\n<td>0<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>3.1.5<\/td>\n<td>3<\/td>\n<td>1<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u4e94\u3001\u603b\u7ed3<\/h3>\n<p>\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86 Hive SQL \u4e2d SUBSTR \u51fd\u6570\u7684\u57fa\u672c\u8bed\u6cd5\u3001\u5e38\u89c1\u5e94\u7528\u573a\u666f\u4ee5\u53ca\u9ad8\u7ea7\u7528\u6cd5\u3002SUBSTR \u51fd\u6570\u4f5c\u4e3a\u4e00\u4e2a\u5f3a\u5927\u7684\u5b57\u7b26\u4e32\u622a\u53d6\u5de5\u5177&#xff0c;\u5728\u5904\u7406\u5404\u79cd\u6587\u672c\u6570\u636e\u65f6\u90fd\u80fd\u53d1\u6325\u91cd\u8981\u4f5c\u7528\u3002\u65e0\u8bba\u662f\u7b80\u5355\u7684\u65e5\u671f\u63d0\u53d6\u3001\u654f\u611f\u4fe1\u606f\u9690\u85cf&#xff0c;\u8fd8\u662f\u590d\u6742\u7684\u5b57\u7b26\u4e32\u6a21\u5f0f\u5904\u7406&#xff0c;\u5408\u7406\u8fd0\u7528 SUBSTR \u51fd\u6570\u90fd\u80fd\u5e2e\u52a9\u6211\u4eec\u9ad8\u6548\u5730\u5b8c\u6210\u6570\u636e\u5904\u7406\u4efb\u52a1\u3002\u5728\u5b9e\u9645\u5de5\u4f5c\u4e2d\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u9700\u6c42\u7075\u6d3b\u8fd0\u7528 SUBSTR \u51fd\u6570&#xff0c;\u5e76\u7ed3\u5408\u5176\u4ed6\u5b57\u7b26\u4e32\u51fd\u6570&#xff0c;\u4ee5\u5b9e\u73b0\u66f4\u52a0\u590d\u6742\u548c\u7cbe\u7ec6\u7684\u6570\u636e\u5904\u7406\u903b\u8f91\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.6k\u6b21\uff0c\u70b9\u8d5e20\u6b21\uff0c\u6536\u85cf26\u6b21\u3002`SUBSTR` \u51fd\u6570\u662f Hive SQL \u4e2d\u4e00\u4e2a\u7528\u4e8e\u5b57\u7b26\u4e32\u622a\u53d6\u7684\u91cd\u8981\u51fd\u6570\uff0c\u5728\u5904\u7406\u6587\u672c\u6570\u636e\u65f6\u53d1\u6325\u7740\u5173\u952e\u4f5c\u7528\u3002\u672c\u6587\u5c06\u5168\u9762\u4e14\u6df1\u5165\u5730\u4ecb\u7ecd Hive SQL \u4e2d `SUBSTR` \u51fd\u6570\u7684\u57fa\u672c\u8bed\u6cd5\u3001\u5e38\u89c1\u5e94\u7528\u573a\u666f\u4ee5\u53ca\u4e00\u4e9b\u9ad8\u7ea7\u7528\u6cd5\u3002_hive substr<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[779,482,1919,768],"topic":[],"class_list":["post-24640","post","type-post","status-publish","format-standard","hentry","category-server","tag-hadoop","tag-hive","tag-hive-sql-","tag-sql"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Hive SQL \u7cbe\u8fdb\u7cfb\u5217\uff1aSUBSTR \u51fd\u6570\u7684\u591a\u6837\u7528\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/24640.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hive SQL \u7cbe\u8fdb\u7cfb\u5217\uff1aSUBSTR \u51fd\u6570\u7684\u591a\u6837\u7528\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.6k\u6b21\uff0c\u70b9\u8d5e20\u6b21\uff0c\u6536\u85cf26\u6b21\u3002`SUBSTR` \u51fd\u6570\u662f Hive SQL \u4e2d\u4e00\u4e2a\u7528\u4e8e\u5b57\u7b26\u4e32\u622a\u53d6\u7684\u91cd\u8981\u51fd\u6570\uff0c\u5728\u5904\u7406\u6587\u672c\u6570\u636e\u65f6\u53d1\u6325\u7740\u5173\u952e\u4f5c\u7528\u3002\u672c\u6587\u5c06\u5168\u9762\u4e14\u6df1\u5165\u5730\u4ecb\u7ecd Hive SQL \u4e2d `SUBSTR` \u51fd\u6570\u7684\u57fa\u672c\u8bed\u6cd5\u3001\u5e38\u89c1\u5e94\u7528\u573a\u666f\u4ee5\u53ca\u4e00\u4e9b\u9ad8\u7ea7\u7528\u6cd5\u3002_hive substr\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/24640.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-19T02:29:11+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/24640.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/24640.html\",\"name\":\"Hive SQL \u7cbe\u8fdb\u7cfb\u5217\uff1aSUBSTR \u51fd\u6570\u7684\u591a\u6837\u7528\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-19T02:29:11+00:00\",\"dateModified\":\"2025-04-19T02:29:11+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/24640.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/24640.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/24640.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hive SQL \u7cbe\u8fdb\u7cfb\u5217\uff1aSUBSTR \u51fd\u6570\u7684\u591a\u6837\u7528\u6cd5\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Hive SQL \u7cbe\u8fdb\u7cfb\u5217\uff1aSUBSTR \u51fd\u6570\u7684\u591a\u6837\u7528\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/24640.html","og_locale":"zh_CN","og_type":"article","og_title":"Hive SQL \u7cbe\u8fdb\u7cfb\u5217\uff1aSUBSTR \u51fd\u6570\u7684\u591a\u6837\u7528\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.6k\u6b21\uff0c\u70b9\u8d5e20\u6b21\uff0c\u6536\u85cf26\u6b21\u3002`SUBSTR` \u51fd\u6570\u662f Hive SQL \u4e2d\u4e00\u4e2a\u7528\u4e8e\u5b57\u7b26\u4e32\u622a\u53d6\u7684\u91cd\u8981\u51fd\u6570\uff0c\u5728\u5904\u7406\u6587\u672c\u6570\u636e\u65f6\u53d1\u6325\u7740\u5173\u952e\u4f5c\u7528\u3002\u672c\u6587\u5c06\u5168\u9762\u4e14\u6df1\u5165\u5730\u4ecb\u7ecd Hive SQL \u4e2d `SUBSTR` \u51fd\u6570\u7684\u57fa\u672c\u8bed\u6cd5\u3001\u5e38\u89c1\u5e94\u7528\u573a\u666f\u4ee5\u53ca\u4e00\u4e9b\u9ad8\u7ea7\u7528\u6cd5\u3002_hive substr","og_url":"https:\/\/www.wsisp.com\/helps\/24640.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-19T02:29:11+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/24640.html","url":"https:\/\/www.wsisp.com\/helps\/24640.html","name":"Hive SQL \u7cbe\u8fdb\u7cfb\u5217\uff1aSUBSTR \u51fd\u6570\u7684\u591a\u6837\u7528\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-19T02:29:11+00:00","dateModified":"2025-04-19T02:29:11+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/24640.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/24640.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/24640.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Hive SQL \u7cbe\u8fdb\u7cfb\u5217\uff1aSUBSTR \u51fd\u6570\u7684\u591a\u6837\u7528\u6cd5"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/24640","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=24640"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/24640\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=24640"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=24640"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=24640"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=24640"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}