{"id":4990,"date":"2024-11-14T09:44:26","date_gmt":"2024-11-14T01:44:26","guid":{"rendered":"https:\/\/fwq.ai\/blog\/4990\/"},"modified":"2024-11-14T09:44:26","modified_gmt":"2024-11-14T01:44:26","slug":"oracle%e4%b8%bb%e9%94%ae%e5%ba%8f%e5%88%97%e6%80%8e%e4%b9%88%e8%8e%b7%e5%be%97","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/4990\/","title":{"rendered":"oracle\u4e3b\u952e\u5e8f\u5217\u600e\u4e48\u83b7\u5f97"},"content":{"rendered":"<blockquote><p>\n  \u83b7\u53d6 oracle \u4e2d\u7684\u4e3b\u952e\u5e8f\u5217\uff0c\u53ef\u4ee5\u901a\u8fc7 sequence \u51fd\u6570\u6216\u67e5\u8be2 sys.sequence \u8868\uff1a\u4f7f\u7528 sequence \u51fd\u6570\uff1aselect sequence.currval from dual\u67e5\u8be2 sys.sequence \u8868\uff1aselect sequence_name, last_number from sys.sequence where sequence_name =\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/21\/2024052108571840363.jpg\" class=\"aligncenter\" title=\"oracle\u4e3b\u952e\u5e8f\u5217\u600e\u4e48\u83b7\u5f97\u63d2\u56fe\" alt=\"oracle\u4e3b\u952e\u5e8f\u5217\u600e\u4e48\u83b7\u5f97\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u83b7\u53d6 Oracle \u4e2d\u7684\u4e3b\u952e\u5e8f\u5217<\/strong><\/p>\n<p>\u4e3b\u952e\u5e8f\u5217\u7528\u4e8e\u5728 Oracle \u6570\u636e\u5e93\u8868\u4e2d\u751f\u6210\u552f\u4e00\u7684\u6807\u8bc6\u7b26\u503c\u3002\u83b7\u53d6\u4e3b\u952e\u5e8f\u5217\u7684\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<p><strong>\u65b9\u6cd5\u4e00\uff1a\u4f7f\u7528 SEQUENCE \u51fd\u6570<\/strong><\/p>\n<pre>SELECT SEQUENCE.currval FROM DUAL;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u65b9\u6cd5\u4e8c\uff1a\u67e5\u8be2 SYS.SEQUENCE \u8868<\/strong><\/p>\n<pre>SELECT sequence_name, last_number FROM SYS.SEQUENCE\nWHERE sequence_name = &lt;sequence_name&gt;;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d\uff0c \u662f\u8981\u83b7\u53d6\u7684\u5e8f\u5217\u7684\u540d\u79f0\u3002 <\/p>\n<p><strong>\u6b65\u9aa4\u8be6\u89e3\uff1a<\/strong><\/p>\n<ol>\n<li> <strong>\u8fde\u63a5\u5230\u6570\u636e\u5e93\uff1a<\/strong>\u4f7f\u7528\u60a8\u559c\u6b22\u7684\u5de5\u5177\u6216\u547d\u4ee4\u884c\u8fde\u63a5\u5230 Oracle \u6570\u636e\u5e93\u3002<\/li>\n<li> <strong>\u6267\u884c\u67e5\u8be2\uff1a<\/strong>\u4f7f\u7528\u4e0a\u8ff0\u65b9\u6cd5\u4e4b\u4e00\u6267\u884c\u67e5\u8be2\u4ee5\u83b7\u53d6\u5e8f\u5217\u7684\u5f53\u524d\u503c\u3002<\/li>\n<li> <strong>\u83b7\u53d6\u7ed3\u679c\uff1a<\/strong>\u67e5\u8be2\u5c06\u8fd4\u56de\u5e8f\u5217\u7684\u5f53\u524d\u503c\u6216\u6709\u5173\u5e8f\u5217\u7684\u4fe1\u606f\u3002<\/li>\n<\/ol>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<p>\u5047\u8bbe\u8868 Customers \u6709\u4e00\u4e2a\u540d\u4e3a customer_id \u7684\u4e3b\u952e\u5217\uff0c\u8be5\u5217\u4f7f\u7528\u5e8f\u5217 customer_id_seq \u751f\u6210\u503c\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u67e5\u8be2\u6765\u83b7\u53d6\u5e8f\u5217\u7684\u5f53\u524d\u503c\uff1a<\/p>\n<pre>SELECT customer_id_seq.currval FROM DUAL;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u8fd4\u56de customer_id_seq \u5e8f\u5217\u7684\u4e0b\u4e00\u4e2a\u53ef\u7528\u7684\u552f\u4e00\u6807\u8bc6\u7b26\u503c\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4e3b\u952e\u5e8f\u5217\u600e\u4e48\u83b7\u5f97\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>\u83b7\u53d6 oracle \u4e2d\u7684\u4e3b\u952e\u5e8f\u5217\uff0c\u53ef\u4ee5\u901a\u8fc7 sequence \u51fd\u6570\u6216\u67e5\u8be2 sys.sequence \u8868\uff1a\u4f7f\u7528 sequence \u51fd\u6570\uff1aselect sequence.currval from dual\u67e5\u8be2 sys.sequence \u8868\uff1aselect sequence_name, last_number from sys.sequence where sequence_name = \u5982\u4f55\u83b7\u53d6 Oracle \u4e2d\u7684\u4e3b\u952e\u5e8f\u5217 \u4e3b\u952e\u5e8f\u5217\u7528\u4e8e\u5728 Oracle \u6570\u636e\u5e93\u8868\u4e2d\u751f\u6210\u552f\u4e00\u7684\u6807\u8bc6\u7b26\u503c\u3002\u83b7\u53d6\u4e3b\u952e\u5e8f\u5217\u7684\u65b9\u6cd5\u5982\u4e0b\uff1a \u65b9\u6cd5\u4e00\uff1a\u4f7f\u7528 SEQUENCE \u51fd\u6570 SELECT SEQUENCE.currval FROM DUAL; \u767b\u5f55\u540e\u590d\u5236 \u65b9\u6cd5\u4e8c\uff1a\u67e5\u8be2 SYS.SEQUENCE \u8868 SELECT sequence_name, last_number FROM SYS.SEQUENCE WHERE sequence_name = &lt;sequence_name&gt;; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff0c \u662f\u8981\u83b7\u53d6\u7684\u5e8f\u5217\u7684\u540d\u79f0\u3002 \u6b65\u9aa4\u8be6\u89e3\uff1a \u8fde\u63a5\u5230\u6570\u636e\u5e93\uff1a\u4f7f\u7528\u60a8\u559c\u6b22\u7684\u5de5\u5177\u6216\u547d\u4ee4\u884c\u8fde\u63a5\u5230 Oracle \u6570\u636e\u5e93\u3002 \u6267\u884c\u67e5\u8be2\uff1a\u4f7f\u7528\u4e0a\u8ff0\u65b9\u6cd5\u4e4b\u4e00\u6267\u884c\u67e5\u8be2\u4ee5\u83b7\u53d6\u5e8f\u5217\u7684\u5f53\u524d\u503c\u3002 [&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-4990","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/4990","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=4990"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/4990\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=4990"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=4990"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=4990"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}