{"id":160165,"date":"2024-11-03T20:49:20","date_gmt":"2024-11-03T12:49:20","guid":{"rendered":"https:\/\/server.hk\/cnblog\/160165\/"},"modified":"2024-11-03T20:49:21","modified_gmt":"2024-11-03T12:49:21","slug":"oceanbase-%e6%95%99%e7%a8%8b%ef%bc%9aoceanbase-lnnvl","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/160165\/","title":{"rendered":"OceanBase \u6559\u7a0b\uff1aOceanBase LNNVL"},"content":{"rendered":"<h1 id=\"oceanbase-%e6%95%99%e7%a8%8b%ef%bc%9aoceanbase-lnnvl-YFfpytsBfF\">OceanBase \u6559\u7a0b\uff1aOceanBase LNNVL<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u6578\u64da\u5eab\u6280\u8853\u4e2d\uff0cOceanBase \u4f5c\u70ba\u4e00\u500b\u9ad8\u6027\u80fd\u7684\u5206\u4f48\u5f0f\u6578\u64da\u5eab\u7cfb\u7d71\uff0c\u8d8a\u4f86\u8d8a\u53d7\u5230\u95dc\u6ce8\u3002\u5b83\u7531\u963f\u91cc\u5df4\u5df4\u96c6\u5718\u958b\u767c\uff0c\u65e8\u5728\u652f\u6301\u5927\u898f\u6a21\u7684\u696d\u52d9\u9700\u6c42\u3002\u672c\u6587\u5c07\u91cd\u9ede\u4ecb\u7d39 OceanBase \u7684 LNNVL\uff08Last Not Null Value\uff09\u529f\u80fd\uff0c\u9019\u662f\u4e00\u500b\u5728\u67e5\u8a62\u4e2d\u8655\u7406\u7a7a\u503c\u7684\u5f37\u5927\u5de5\u5177\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%af-lnnvl%ef%bc%9f-YFfpytsBfF\">\u4ec0\u9ebc\u662f LNNVL\uff1f<\/h2>\n<p>LNNVL \u662f OceanBase \u4e2d\u7684\u4e00\u500b SQL \u51fd\u6578\uff0c\u7528\u65bc\u5728\u67e5\u8a62\u4e2d\u8fd4\u56de\u6700\u5f8c\u4e00\u500b\u975e\u7a7a\u503c\u3002\u9019\u5728\u8655\u7406\u6578\u64da\u6642\u7279\u5225\u6709\u7528\uff0c\u56e0\u70ba\u5728\u8a31\u591a\u60c5\u6cc1\u4e0b\uff0c\u6578\u64da\u96c6\u4e2d\u53ef\u80fd\u5b58\u5728\u5927\u91cf\u7684\u7a7a\u503c\uff0c\u800c\u9019\u4e9b\u7a7a\u503c\u53ef\u80fd\u6703\u5f71\u97ff\u67e5\u8a62\u7d50\u679c\u7684\u6e96\u78ba\u6027\u548c\u5b8c\u6574\u6027\u3002<\/p>\n<h2 id=\"lnnvl-%e7%9a%84%e4%bd%bf%e7%94%a8%e5%a0%b4%e6%99%af-YFfpytsBfF\">LNNVL \u7684\u4f7f\u7528\u5834\u666f<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e9b\u4f7f\u7528 LNNVL \u7684\u5178\u578b\u5834\u666f\uff1a<\/p>\n<ul>\n<li><strong>\u6578\u64da\u6e05\u7406\uff1a<\/strong>\u5728\u6578\u64da\u5206\u6790\u904e\u7a0b\u4e2d\uff0c\u7d93\u5e38\u9700\u8981\u6e05\u7406\u6578\u64da\u96c6\uff0c\u53bb\u9664\u7a7a\u503c\u4ee5\u7372\u5f97\u66f4\u6e96\u78ba\u7684\u7d50\u679c\u3002<\/li>\n<li><strong>\u5831\u544a\u751f\u6210\uff1a<\/strong>\u5728\u751f\u6210\u5831\u544a\u6642\uff0c\u53ef\u80fd\u9700\u8981\u986f\u793a\u6700\u5f8c\u4e00\u500b\u6709\u6548\u6578\u64da\u9ede\uff0c\u4ee5\u4fbf\u66f4\u597d\u5730\u7406\u89e3\u6578\u64da\u8da8\u52e2\u3002<\/li>\n<li><strong>\u6578\u64da\u586b\u5145\uff1a<\/strong>\u5728\u67d0\u4e9b\u60c5\u6cc1\u4e0b\uff0c\u53ef\u80fd\u9700\u8981\u7528\u6700\u5f8c\u4e00\u500b\u975e\u7a7a\u503c\u586b\u5145\u7a7a\u503c\uff0c\u4ee5\u4fdd\u6301\u6578\u64da\u7684\u9023\u8cab\u6027\u3002<\/li>\n<\/ul>\n<h2 id=\"lnnvl-%e7%9a%84%e8%aa%9e%e6%b3%95-YFfpytsBfF\">LNNVL \u7684\u8a9e\u6cd5<\/h2>\n<p>LNNVL \u7684\u57fa\u672c\u8a9e\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre><code>\nLNNVL(expression)\n<\/code><\/pre>\n<p>\u5176\u4e2d\uff0c<code>expression<\/code> \u662f\u8981\u8a55\u4f30\u7684\u8868\u9054\u5f0f\u3002\u7576\u8a72\u8868\u9054\u5f0f\u7684\u503c\u70ba\u7a7a\u6642\uff0cLNNVL \u5c07\u8fd4\u56de\u6700\u5f8c\u4e00\u500b\u975e\u7a7a\u503c\u3002<\/p>\n<h2 id=\"%e7%a4%ba%e4%be%8b-YFfpytsBfF\">\u793a\u4f8b<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u500b\u4f7f\u7528 LNNVL \u7684\u793a\u4f8b\uff0c\u5047\u8a2d\u6211\u5011\u6709\u4e00\u500b\u540d\u70ba <code>sales<\/code> \u7684\u8868\uff0c\u8a72\u8868\u5305\u542b\u4ee5\u4e0b\u6578\u64da\uff1a<\/p>\n<pre><code>\n+-------+-------+\n| month | sales |\n+-------+-------+\n| Jan   | 100   |\n| Feb   | NULL  |\n| Mar   | 150   |\n| Apr   | NULL  |\n| May   | 200   |\n+-------+-------+\n<\/code><\/pre>\n<p>\u5982\u679c\u6211\u5011\u60f3\u8981\u67e5\u8a62\u6bcf\u500b\u6708\u4efd\u7684\u92b7\u552e\u6578\u64da\uff0c\u4e26\u7528\u6700\u5f8c\u4e00\u500b\u975e\u7a7a\u503c\u586b\u5145\u7a7a\u503c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b SQL \u67e5\u8a62\uff1a<\/p>\n<pre><code>\nSELECT month, \n       LNNVL(sales) AS last_sales \nFROM sales;\n<\/code><\/pre>\n<p>\u9019\u5c07\u8fd4\u56de\u4ee5\u4e0b\u7d50\u679c\uff1a<\/p>\n<pre><code>\n+-------+------------+\n| month | last_sales |\n+-------+------------+\n| Jan   | 100        |\n| Feb   | 100        |\n| Mar   | 150        |\n| Apr   | 150        |\n| May   | 200        |\n+-------+------------+\n<\/code><\/pre>\n<h2 id=\"%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a0%85-YFfpytsBfF\">\u6ce8\u610f\u4e8b\u9805<\/h2>\n<p>\u5728\u4f7f\u7528 LNNVL \u6642\uff0c\u6709\u5e7e\u9ede\u9700\u8981\u6ce8\u610f\uff1a<\/p>\n<ul>\n<li>LNNVL \u53ea\u6703\u8fd4\u56de\u6700\u5f8c\u4e00\u500b\u975e\u7a7a\u503c\uff0c\u5982\u679c\u6574\u500b\u6578\u64da\u96c6\u90fd\u662f\u7a7a\u503c\uff0c\u5247\u7d50\u679c\u5c07\u70ba\u7a7a\u3002<\/li>\n<li>\u5728\u6027\u80fd\u65b9\u9762\uff0c\u4f7f\u7528 LNNVL \u53ef\u80fd\u6703\u5f71\u97ff\u67e5\u8a62\u7684\u57f7\u884c\u901f\u5ea6\uff0c\u7279\u5225\u662f\u5728\u8655\u7406\u5927\u91cf\u6578\u64da\u6642\uff0c\u56e0\u6b64\u5efa\u8b70\u5728\u5fc5\u8981\u6642\u4f7f\u7528\u3002<\/li>\n<li>\u78ba\u4fdd\u5728\u4f7f\u7528 LNNVL \u7684\u8868\u9054\u5f0f\u4e2d\uff0c\u6578\u64da\u985e\u578b\u7684\u4e00\u81f4\u6027\uff0c\u4ee5\u907f\u514d\u985e\u578b\u4e0d\u5339\u914d\u7684\u932f\u8aa4\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-YFfpytsBfF\">\u7e3d\u7d50<\/h2>\n<p>OceanBase \u7684 LNNVL \u529f\u80fd\u70ba\u6578\u64da\u8655\u7406\u63d0\u4f9b\u4e86\u4e00\u7a2e\u6709\u6548\u7684\u65b9\u5f0f\uff0c\u7279\u5225\u662f\u5728\u9762\u5c0d\u7a7a\u503c\u6642\u3002\u901a\u904e\u4f7f\u7528 LNNVL\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u66f4\u8f15\u9b06\u5730\u7ba1\u7406\u548c\u5206\u6790\u6578\u64da\uff0c\u5f9e\u800c\u63d0\u9ad8\u6578\u64da\u7684\u6e96\u78ba\u6027\u548c\u53ef\u7528\u6027\u3002\u5982\u679c\u60a8\u5c0d\u65bc\u5982\u4f55\u5728\u60a8\u7684\u9805\u76ee\u4e2d\u4f7f\u7528 OceanBase \u6216\u8005\u9700\u8981\u66f4\u591a\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9\u4ee5\u7372\u53d6\u66f4\u591a\u4fe1\u606f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22 OceanBase LNNVL \u7684\u5168\u9762\u6559\u7a0b\uff0c\u638c\u63e1\u9ad8\u6548\u6570\u636e\u7ba1\u7406\u4e0e\u67e5\u8be2\u6280\u5de7\uff0c\u63d0\u5347\u6570\u636e\u5e93\u6027\u80fd\u4e0e\u5e94\u7528\u80fd\u529b\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-160165","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/160165","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=160165"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/160165\/revisions"}],"predecessor-version":[{"id":160166,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/160165\/revisions\/160166"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=160165"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=160165"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=160165"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}