{"id":6099,"date":"2024-11-14T12:58:13","date_gmt":"2024-11-14T04:58:13","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6099\/"},"modified":"2024-11-14T12:58:13","modified_gmt":"2024-11-14T04:58:13","slug":"oracle%e5%ba%8f%e5%88%97%e5%a6%82%e4%bd%95%e7%94%a8","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6099\/","title":{"rendered":"oracle\u5e8f\u5217\u5982\u4f55\u7528"},"content":{"rendered":"<blockquote><p>\n  oracle \u5e8f\u5217\u7528\u4e8e\u751f\u6210\u552f\u4e00\u6570\u5b57\u5e8f\u5217\uff0c\u901a\u5e38\u7528\u4f5c\u4e3b\u952e\u6216\u6807\u8bc6\u7b26\u3002\u521b\u5efa\u5e8f\u5217\u9700\u8981\u6307\u5b9a\u5e8f\u5217\u540d\u79f0\u3001\u8d77\u59cb\u503c\u3001\u589e\u91cf\u503c\u3001\u6700\u5927\u503c\u3001\u6700\u5c0f\u503c\u3001\u7f13\u5b58\u5927\u5c0f\u548c\u5faa\u73af\u6807\u5fd7\u3002\u4f7f\u7528\u5e8f\u5217\u65f6\uff0c\u4f7f\u7528 nextval \u5173\u952e\u5b57\u83b7\u53d6\u5e8f\u5217\u7684\u4e0b\u4e00\u4e2a\u503c\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/12\/2024061223091976352.jpg\" class=\"aligncenter\" title=\"oracle\u5e8f\u5217\u5982\u4f55\u7528\u63d2\u56fe\" alt=\"oracle\u5e8f\u5217\u5982\u4f55\u7528\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528 Oracle \u5e8f\u5217<\/strong><\/p>\n<p>Oracle \u5e8f\u5217\u662f\u4e00\u79cd\u7528\u4e8e\u751f\u6210\u4e00\u7cfb\u5217\u552f\u4e00\u6570\u5b57\u7684\u6570\u636e\u5e93\u5bf9\u8c61\u3002\u5b83\u901a\u5e38\u7528\u4e8e\u4e3a\u8868\u4e2d\u7684\u8bb0\u5f55\u5206\u914d\u4e3b\u952e\u6216\u5176\u4ed6\u6807\u8bc6\u7b26\u3002<\/p>\n<p><strong>\u521b\u5efa\u5e8f\u5217<\/strong><\/p>\n<p>\u8981\u521b\u5efa\u5e8f\u5217\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a<\/p>\n<pre>CREATE SEQUENCE sequence_name\nSTART WITH start_value\nINCREMENT BY increment_value\nMAXVALUE max_value\nMINVALUE min_value\nCACHE size\nCYCLE;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li> <strong>sequence_name\uff1a<\/strong>\u5e8f\u5217\u7684\u540d\u79f0\u3002<\/li>\n<li> <strong>start_value\uff1a<\/strong>\u5e8f\u5217\u7684\u8d77\u59cb\u503c\u3002<\/li>\n<li> <strong>increment_value\uff1a<\/strong>\u6bcf\u6b21\u8c03\u7528\u5e8f\u5217\u65f6\u5e8f\u5217\u589e\u957f\u7684\u503c\u3002<\/li>\n<li> <strong>max_value\uff1a<\/strong>\u5e8f\u5217\u7684\u6700\u5927\u503c\u3002<\/li>\n<li> <strong>min_value\uff1a<\/strong>\u5e8f\u5217\u7684\u6700\u5c0f\u503c\u3002<\/li>\n<li> <strong>CACHE\uff1a<\/strong>\u6307\u5b9a\u5e8f\u5217\u7f13\u5b58\u5728\u5185\u5b58\u4e2d\u7684\u5927\u5c0f\u3002<\/li>\n<li> <strong>CYCLE\uff1a<\/strong>\u6307\u793a\u5e8f\u5217\u5728\u8fbe\u5230 max_value \u540e\u662f\u5426\u5e94\u91cd\u65b0\u5f00\u59cb\u4ece start_value\u3002<\/li>\n<\/ul>\n<p><strong>\u4f7f\u7528\u5e8f\u5217<\/strong><\/p>\n<p>\u8981\u4f7f\u7528\u5e8f\u5217\uff0c\u8bf7\u4f7f\u7528 NEXTVAL \u5173\u952e\u5b57\u3002\u8fd9\u5c06\u8fd4\u56de\u5e8f\u5217\u7684\u4e0b\u4e00\u4e2a\u503c\uff1a<\/p>\n<pre>SELECT NEXTVAL('sequence_name');<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u793a\u4f8b<\/strong><\/p>\n<p>\u4ee5\u4e0b\u793a\u4f8b\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3a my_sequence \u7684\u5e8f\u5217\uff0c\u4ece 1 \u5f00\u59cb\uff0c\u6bcf\u6b21\u8c03\u7528\u589e\u52a0 1\uff0c\u6700\u5927\u503c\u4e3a 100000\uff1a<\/p>\n<pre>CREATE SEQUENCE my_sequence\nSTART WITH 1\nINCREMENT BY 1\nMAXVALUE 100000;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8981\u4f7f\u7528\u6b64\u5e8f\u5217\uff0c\u6211\u4eec\u53ef\u4ee5\u8fd0\u884c\u4ee5\u4e0b\u67e5\u8be2\uff1a<\/p>\n<pre>SELECT NEXTVAL('my_sequence');<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u8fd4\u56de\u5e8f\u5217\u7684\u5f53\u524d\u503c\uff0c\u5373 1\u3002\u518d\u6b21\u8fd0\u884c\u67e5\u8be2\u5c06\u8fd4\u56de 2\uff0c\u4f9d\u6b64\u7c7b\u63a8\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5e8f\u5217\u5982\u4f55\u7528\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 \u5e8f\u5217\u7528\u4e8e\u751f\u6210\u552f\u4e00\u6570\u5b57\u5e8f\u5217\uff0c\u901a\u5e38\u7528\u4f5c\u4e3b\u952e\u6216\u6807\u8bc6\u7b26\u3002\u521b\u5efa\u5e8f\u5217\u9700\u8981\u6307\u5b9a\u5e8f\u5217\u540d\u79f0\u3001\u8d77\u59cb\u503c\u3001\u589e\u91cf\u503c\u3001\u6700\u5927\u503c\u3001\u6700\u5c0f\u503c\u3001\u7f13\u5b58\u5927\u5c0f\u548c\u5faa\u73af\u6807\u5fd7\u3002\u4f7f\u7528\u5e8f\u5217\u65f6\uff0c\u4f7f\u7528 nextval \u5173\u952e\u5b57\u83b7\u53d6\u5e8f\u5217\u7684\u4e0b\u4e00\u4e2a\u503c\u3002 \u5982\u4f55\u4f7f\u7528 Oracle \u5e8f\u5217 Oracle \u5e8f\u5217\u662f\u4e00\u79cd\u7528\u4e8e\u751f\u6210\u4e00\u7cfb\u5217\u552f\u4e00\u6570\u5b57\u7684\u6570\u636e\u5e93\u5bf9\u8c61\u3002\u5b83\u901a\u5e38\u7528\u4e8e\u4e3a\u8868\u4e2d\u7684\u8bb0\u5f55\u5206\u914d\u4e3b\u952e\u6216\u5176\u4ed6\u6807\u8bc6\u7b26\u3002 \u521b\u5efa\u5e8f\u5217 \u8981\u521b\u5efa\u5e8f\u5217\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a CREATE SEQUENCE sequence_name START WITH start_value INCREMENT BY increment_value MAXVALUE max_value MINVALUE min_value CACHE size CYCLE; \u767b\u5f55\u540e\u590d\u5236 sequence_name\uff1a\u5e8f\u5217\u7684\u540d\u79f0\u3002 start_value\uff1a\u5e8f\u5217\u7684\u8d77\u59cb\u503c\u3002 increment_value\uff1a\u6bcf\u6b21\u8c03\u7528\u5e8f\u5217\u65f6\u5e8f\u5217\u589e\u957f\u7684\u503c\u3002 max_value\uff1a\u5e8f\u5217\u7684\u6700\u5927\u503c\u3002 min_value\uff1a\u5e8f\u5217\u7684\u6700\u5c0f\u503c\u3002 CACHE\uff1a\u6307\u5b9a\u5e8f\u5217\u7f13\u5b58\u5728\u5185\u5b58\u4e2d\u7684\u5927\u5c0f\u3002 CYCLE\uff1a\u6307\u793a\u5e8f\u5217\u5728\u8fbe\u5230 max_value \u540e\u662f\u5426\u5e94\u91cd\u65b0\u5f00\u59cb\u4ece start_value\u3002 \u4f7f\u7528\u5e8f\u5217 \u8981\u4f7f\u7528\u5e8f\u5217\uff0c\u8bf7\u4f7f\u7528 NEXTVAL \u5173\u952e\u5b57\u3002\u8fd9\u5c06\u8fd4\u56de\u5e8f\u5217\u7684\u4e0b\u4e00\u4e2a\u503c\uff1a SELECT NEXTVAL(&#8216;sequence_name&#8217;); \u767b\u5f55\u540e\u590d\u5236 \u793a\u4f8b \u4ee5\u4e0b\u793a\u4f8b\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3a my_sequence \u7684\u5e8f\u5217\uff0c\u4ece 1 \u5f00\u59cb\uff0c\u6bcf\u6b21\u8c03\u7528\u589e\u52a0 1\uff0c\u6700\u5927\u503c\u4e3a 100000\uff1a CREATE SEQUENCE [&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-6099","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6099","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=6099"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6099\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6099"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6099"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6099"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}