{"id":5749,"date":"2024-11-14T12:17:56","date_gmt":"2024-11-14T04:17:56","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5749\/"},"modified":"2024-11-14T12:17:56","modified_gmt":"2024-11-14T04:17:56","slug":"oracle%e5%ba%8f%e5%88%97%e6%80%8e%e4%b9%88%e5%8f%96%e5%87%ba%e6%9d%a5","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5749\/","title":{"rendered":"oracle\u5e8f\u5217\u600e\u4e48\u53d6\u51fa\u6765"},"content":{"rendered":"<blockquote><p>\n  \u83b7\u53d6 oracle \u5e8f\u5217\u503c\u6709\u4e24\u79cd\u65b9\u6cd5\uff1a\u4f7f\u7528 nextval \u51fd\u6570\u8fd4\u56de\u5e8f\u5217\u7684\u4e0b\u4e00\u4e2a\u503c\u5e76\u5c06\u5176\u52a0 1\uff0c\u6216\u4f7f\u7528 currval \u51fd\u6570\u8fd4\u56de\u5e8f\u5217\u7684\u5f53\u524d\u503c\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/30\/2024053021580013920.jpg\" class=\"aligncenter\" title=\"oracle\u5e8f\u5217\u600e\u4e48\u53d6\u51fa\u6765\u63d2\u56fe\" alt=\"oracle\u5e8f\u5217\u600e\u4e48\u53d6\u51fa\u6765\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u83b7\u53d6 Oracle \u5e8f\u5217\u503c<\/strong><\/p>\n<p>\u83b7\u53d6 Oracle \u5e8f\u5217\u503c\u7684\u65b9\u6cd5\u6709\u4e24\u79cd\uff1a<\/p>\n<p><strong>1. \u4f7f\u7528 NEXTVAL \u51fd\u6570<\/strong><\/p>\n<p>NEXTVAL \u51fd\u6570\u8fd4\u56de\u5e8f\u5217\u7684\u4e0b\u4e00\u4e2a\u503c\uff0c\u5e76\u5c06\u5e8f\u5217\u7684\u503c\u52a0 1\u3002\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre>SELECT NEXTVAL(sequence_name)<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<pre>SELECT NEXTVAL('CUSTOMER_SEQ')<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. \u4f7f\u7528 CURRVAL \u51fd\u6570<\/strong><\/p>\n<p>CURRVAL \u51fd\u6570\u8fd4\u56de\u5e8f\u5217\u7684\u5f53\u524d\u503c\u3002\u4e0e NEXTVAL \u51fd\u6570\u4e0d\u540c\uff0c\u5b83\u4e0d\u4f1a\u589e\u52a0\u5e8f\u5217\u7684\u503c\u3002\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre>SELECT CURRVAL(sequence_name)<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<pre>SELECT CURRVAL('CUSTOMER_SEQ')<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u4f7f\u7528\u6848\u4f8b<\/strong><\/p>\n<p>\u83b7\u53d6\u5e8f\u5217\u503c\u7528\u4e8e\u751f\u6210\u552f\u4e00\u6807\u8bc6\u7b26\uff1a<\/p>\n<pre>INSERT INTO CUSTOMERS (CUSTOMER_ID, NAME)\nVALUES (NEXTVAL('CUSTOMER_SEQ'), 'John Doe');<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u63d0\u793a<\/strong><\/p>\n<ul>\n<li>\u786e\u4fdd\u5e8f\u5217\u5df2\u521b\u5efa\u5e76\u6b63\u786e\u914d\u7f6e\u3002<\/li>\n<li>\u5bf9\u4e8e\u9700\u8981\u552f\u4e00\u503c\u7684\u8868\uff0c\u4f7f\u7528\u5e8f\u5217\u662f\u4e00\u79cd\u6709\u6548\u7684\u65b9\u5f0f\u6765\u751f\u6210 ID\u3002<\/li>\n<li>\u6839\u636e\u9700\u8981\uff0c\u53ef\u4ee5\u4f7f\u7528 INCREMENT \u548c MINVALUE \u7b49\u5e8f\u5217\u5c5e\u6027\u6765\u81ea\u5b9a\u4e49\u5e8f\u5217\u7684\u884c\u4e3a\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5e8f\u5217\u600e\u4e48\u53d6\u51fa\u6765\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 \u5e8f\u5217\u503c\u6709\u4e24\u79cd\u65b9\u6cd5\uff1a\u4f7f\u7528 nextval \u51fd\u6570\u8fd4\u56de\u5e8f\u5217\u7684\u4e0b\u4e00\u4e2a\u503c\u5e76\u5c06\u5176\u52a0 1\uff0c\u6216\u4f7f\u7528 currval \u51fd\u6570\u8fd4\u56de\u5e8f\u5217\u7684\u5f53\u524d\u503c\u3002 \u5982\u4f55\u83b7\u53d6 Oracle \u5e8f\u5217\u503c \u83b7\u53d6 Oracle \u5e8f\u5217\u503c\u7684\u65b9\u6cd5\u6709\u4e24\u79cd\uff1a 1. \u4f7f\u7528 NEXTVAL \u51fd\u6570 NEXTVAL \u51fd\u6570\u8fd4\u56de\u5e8f\u5217\u7684\u4e0b\u4e00\u4e2a\u503c\uff0c\u5e76\u5c06\u5e8f\u5217\u7684\u503c\u52a0 1\u3002\u8bed\u6cd5\u5982\u4e0b\uff1a SELECT NEXTVAL(sequence_name) \u767b\u5f55\u540e\u590d\u5236 \u4f8b\u5982\uff1a SELECT NEXTVAL(&#8216;CUSTOMER_SEQ&#8217;) \u767b\u5f55\u540e\u590d\u5236 2. \u4f7f\u7528 CURRVAL \u51fd\u6570 CURRVAL \u51fd\u6570\u8fd4\u56de\u5e8f\u5217\u7684\u5f53\u524d\u503c\u3002\u4e0e NEXTVAL \u51fd\u6570\u4e0d\u540c\uff0c\u5b83\u4e0d\u4f1a\u589e\u52a0\u5e8f\u5217\u7684\u503c\u3002\u8bed\u6cd5\u5982\u4e0b\uff1a SELECT CURRVAL(sequence_name) \u767b\u5f55\u540e\u590d\u5236 \u4f8b\u5982\uff1a SELECT CURRVAL(&#8216;CUSTOMER_SEQ&#8217;) \u767b\u5f55\u540e\u590d\u5236 \u4f7f\u7528\u6848\u4f8b \u83b7\u53d6\u5e8f\u5217\u503c\u7528\u4e8e\u751f\u6210\u552f\u4e00\u6807\u8bc6\u7b26\uff1a INSERT INTO CUSTOMERS (CUSTOMER_ID, NAME) VALUES (NEXTVAL(&#8216;CUSTOMER_SEQ&#8217;), &#8216;John Doe&#8217;); \u767b\u5f55\u540e\u590d\u5236 [&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-5749","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5749","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=5749"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5749\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5749"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5749"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5749"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}