{"id":5331,"date":"2024-11-14T11:48:35","date_gmt":"2024-11-14T03:48:35","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5331\/"},"modified":"2024-11-14T11:48:35","modified_gmt":"2024-11-14T03:48:35","slug":"oracle%e6%80%8e%e4%b9%88%e9%99%90%e5%88%b6%e6%9d%a1%e6%95%b0","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5331\/","title":{"rendered":"oracle\u600e\u4e48\u9650\u5236\u6761\u6570"},"content":{"rendered":"<blockquote><p>\n  oracle \u4e2d\u9650\u5236\u67e5\u8be2\u7ed3\u679c\u7684\u884c\u6570\u6709\u4e09\u79cd\u65b9\u6cd5\uff1a\u4f7f\u7528 rownum \u4f2a\u5217\u6307\u5b9a\u7279\u5b9a\u884c\u53f7\u8303\u56f4\uff1aselect * from table_name where rownum\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/26\/2024052619423933033.jpg\" class=\"aligncenter\" title=\"oracle\u600e\u4e48\u9650\u5236\u6761\u6570\u63d2\u56fe\" alt=\"oracle\u600e\u4e48\u9650\u5236\u6761\u6570\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728 Oracle \u4e2d\u9650\u5236\u67e5\u8be2\u7ed3\u679c\u7684\u884c\u6570<\/strong><\/p>\n<p>Oracle \u63d0\u4f9b\u4e86\u591a\u79cd\u65b9\u6cd5\u6765\u9650\u5236\u67e5\u8be2\u8fd4\u56de\u7684\u884c\u6570\u3002\u6700\u5e38\u7528\u7684\u662f ROWNUM \u4f2a\u5217\u548c LIMIT \u5b50\u53e5\u3002<\/p>\n<p><strong>\u4f7f\u7528 ROWNUM \u4f2a\u5217<\/strong><\/p>\n<p>ROWNUM \u4f2a\u5217\u8868\u793a\u5f53\u524d\u6b63\u5728\u5904\u7406\u7684\u884c\u7684\u884c\u53f7\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u5b83\u6765\u4ec5\u9009\u62e9\u7279\u5b9a\u884c\u53f7\u8303\u56f4\u7684\u884c\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>SELECT * FROM table_name WHERE ROWNUM &lt;= 10;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u8fd4\u56de table_name \u8868\u4e2d\u524d 10 \u884c\u7684\u6570\u636e\u3002<\/p>\n<p><strong>\u4f7f\u7528 LIMIT \u5b50\u53e5<\/strong><\/p>\n<p>LIMIT \u5b50\u53e5\u5141\u8bb8\u60a8\u6307\u5b9a\u8981\u8fd4\u56de\u7684\u884c\u6570\u3002\u5b83\u4e0e ROWNUM \u4f2a\u5217\u4e00\u8d77\u4f7f\u7528\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>SELECT * FROM table_name ORDER BY some_column LIMIT 10;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u8fd4\u56de table_name \u8868\u4e2d\u6309 some_column \u5217\u6392\u5e8f\u7684\u524d 10 \u884c\u6570\u636e\u3002<\/p>\n<p><strong>\u9650\u5236\u5e26\u5206\u9875\u7684\u67e5\u8be2<\/strong><\/p>\n<p>\u8981\u9650\u5236\u5e26\u5206\u9875\u7684\u67e5\u8be2\uff0c\u53ef\u4ee5\u4f7f\u7528 ROWNUM \u4f2a\u5217\u548c OFFSET \u5b50\u53e5\u3002OFFSET \u5b50\u53e5\u6307\u5b9a\u8981\u8df3\u8fc7\u7684\u884c\u6570\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>SELECT * FROM table_name ORDER BY some_column LIMIT 10 OFFSET 10;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u8fd4\u56de table_name \u8868\u4e2d\u6309 some_column \u5217\u6392\u5e8f\uff0c\u4ece\u7b2c 11 \u884c\u5f00\u59cb\u7684 10 \u884c\u6570\u636e\u3002<\/p>\n<p><strong>\u6ce8\u610f\uff1a<\/strong><\/p>\n<ul>\n<li>ROWNUM \u4f2a\u5217\u4ece 1 \u5f00\u59cb\u3002<\/li>\n<li>LIMIT \u5b50\u53e5\u548c OFFSET \u5b50\u53e5\u4e0d\u80fd\u4e00\u8d77\u4f7f\u7528\u3002<\/li>\n<li>Oracle \u4e2d\u7684\u884c\u6570\u9650\u5236\u4e3a 21 \u4ebf\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u9650\u5236\u6761\u6570\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>oracle \u4e2d\u9650\u5236\u67e5\u8be2\u7ed3\u679c\u7684\u884c\u6570\u6709\u4e09\u79cd\u65b9\u6cd5\uff1a\u4f7f\u7528 rownum \u4f2a\u5217\u6307\u5b9a\u7279\u5b9a\u884c\u53f7\u8303\u56f4\uff1aselect * from table_name where rownum \u5982\u4f55\u5728 Oracle \u4e2d\u9650\u5236\u67e5\u8be2\u7ed3\u679c\u7684\u884c\u6570 Oracle \u63d0\u4f9b\u4e86\u591a\u79cd\u65b9\u6cd5\u6765\u9650\u5236\u67e5\u8be2\u8fd4\u56de\u7684\u884c\u6570\u3002\u6700\u5e38\u7528\u7684\u662f ROWNUM \u4f2a\u5217\u548c LIMIT \u5b50\u53e5\u3002 \u4f7f\u7528 ROWNUM \u4f2a\u5217 ROWNUM \u4f2a\u5217\u8868\u793a\u5f53\u524d\u6b63\u5728\u5904\u7406\u7684\u884c\u7684\u884c\u53f7\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u5b83\u6765\u4ec5\u9009\u62e9\u7279\u5b9a\u884c\u53f7\u8303\u56f4\u7684\u884c\u3002\u4f8b\u5982\uff1a SELECT * FROM table_name WHERE ROWNUM &lt;= 10; \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u5c06\u8fd4\u56de table_name \u8868\u4e2d\u524d 10 \u884c\u7684\u6570\u636e\u3002 \u4f7f\u7528 LIMIT \u5b50\u53e5 LIMIT \u5b50\u53e5\u5141\u8bb8\u60a8\u6307\u5b9a\u8981\u8fd4\u56de\u7684\u884c\u6570\u3002\u5b83\u4e0e ROWNUM \u4f2a\u5217\u4e00\u8d77\u4f7f\u7528\u3002\u4f8b\u5982\uff1a SELECT * FROM table_name ORDER BY some_column LIMIT 10; \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u5c06\u8fd4\u56de [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-5331","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5331","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=5331"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5331\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5331"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5331"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5331"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}