{"id":6069,"date":"2024-11-14T10:34:49","date_gmt":"2024-11-14T02:34:49","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6069\/"},"modified":"2024-11-14T10:34:49","modified_gmt":"2024-11-14T02:34:49","slug":"oracle%e5%a6%82%e4%bd%95%e5%88%9b%e5%bb%ba%e7%b4%a2%e5%bc%95","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6069\/","title":{"rendered":"oracle\u5982\u4f55\u521b\u5efa\u7d22\u5f15"},"content":{"rendered":"<blockquote><p>\n  oracle \u4e2d\u521b\u5efa\u7d22\u5f15\u9700\u9075\u5faa\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u786e\u5b9a\u8868\u548c\u7d22\u5f15\u5217\u3002\u4f7f\u7528 create index \u8bed\u53e5\uff0c\u6307\u5b9a\u7d22\u5f15\u540d\u79f0\u3001\u8868\u540d\u79f0\u548c\u5217\u540d\u79f0\u3002\u6307\u5b9a\u7d22\u5f15\u7c7b\u578b\uff08\u9ed8\u8ba4 b-tree\uff09\uff0c\u5e76\u53ef\u6dfb\u52a0 unique\u3001primary key \u7b49\u9009\u9879\u3002\u6ce8\u610f\u4e8b\u9879\u5305\u62ec\u6027\u80fd\u5f71\u54cd\u3001\u7ef4\u62a4\u5f00\u9500\u3001\u7a7a\u95f4\u9700\u6c42\u548c\u9009\u62e9\u6027\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/12\/2024061220452150254.jpg\" class=\"aligncenter\" title=\"oracle\u5982\u4f55\u521b\u5efa\u7d22\u5f15\u63d2\u56fe\" alt=\"oracle\u5982\u4f55\u521b\u5efa\u7d22\u5f15\u63d2\u56fe\" \/><\/p>\n<p><strong>\u4f7f\u7528 Oracle \u521b\u5efa\u7d22\u5f15<\/strong><\/p>\n<p>\u7d22\u5f15\u662f\u4e00\u79cd\u6570\u636e\u5e93\u5bf9\u8c61\uff0c\u7528\u4e8e\u52a0\u5feb\u5bf9\u8868\u4e2d\u6570\u636e\u7684\u68c0\u7d22\u901f\u5ea6\u3002\u5728 Oracle \u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u521b\u5efa\u7d22\u5f15\uff1a<\/p>\n<p><strong>1. \u786e\u5b9a\u8981\u521b\u5efa\u7d22\u5f15\u7684\u8868\u548c\u5217<\/strong><\/p>\n<p>\u9996\u5148\uff0c\u786e\u5b9a\u8981\u4e3a\u5176\u521b\u5efa\u7d22\u5f15\u7684\u8868\u548c\u5217\u3002\u9009\u62e9\u90a3\u4e9b\u5728\u67e5\u8be2\u4e2d\u7ecf\u5e38\u4f7f\u7528\u6216\u52a0\u5165\u7684\u5217\u3002<\/p>\n<p><strong>2. \u4f7f\u7528 CREATE INDEX \u8bed\u53e5<\/strong><\/p>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\u521b\u5efa\u7d22\u5f15\uff1a<\/p>\n<pre>CREATE INDEX [\u7d22\u5f15\u540d\u79f0] ON [\u8868\u540d\u79f0] ([\u5217\u540d\u79f0]);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4f8b\u5982\uff0c\u8981\u4e3a\u540d\u4e3a &#8220;products&#8221; \u7684\u8868\u4e2d\u7684 &#8220;product_name&#8221; \u5217\u521b\u5efa\u7d22\u5f15\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\uff1a<\/p>\n<pre>CREATE INDEX idx_product_name ON products (product_name);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>3. \u6307\u5b9a\u7d22\u5f15\u7c7b\u578b<\/strong><\/p>\n<p>Oracle \u652f\u6301\u591a\u79cd\u7d22\u5f15\u7c7b\u578b\uff0c\u5305\u62ec B-Tree \u7d22\u5f15\u3001\u4f4d\u56fe\u7d22\u5f15\u548c\u51fd\u6570\u7d22\u5f15\u3002\u5982\u679c\u672a\u6307\u5b9a\u7d22\u5f15\u7c7b\u578b\uff0cOracle \u5c06\u9ed8\u8ba4\u521b\u5efa B-Tree \u7d22\u5f15\u3002<\/p>\n<p><strong>4. \u6307\u5b9a\u5176\u4ed6\u9009\u9879<\/strong><\/p>\n<p>\u521b\u5efa\u7d22\u5f15\u65f6\uff0c\u53ef\u4ee5\u6307\u5b9a\u4ee5\u4e0b\u9644\u52a0\u9009\u9879\uff1a<\/p>\n<ul>\n<li> <strong>UNIQUE\uff1a<\/strong>\u6307\u5b9a\u7d22\u5f15\u4e2d\u4e0d\u5141\u8bb8\u91cd\u590d\u503c\u3002<\/li>\n<li> <strong>PRIMARY KEY\uff1a<\/strong>\u6307\u5b9a\u7d22\u5f15\u4f5c\u4e3a\u8868\u7684\u552f\u4e00\u6807\u8bc6\u7b26\u3002<\/li>\n<li> <strong>BITMAP\uff1a<\/strong>\u6307\u5b9a\u8981\u521b\u5efa\u4f4d\u56fe\u7d22\u5f15\u3002<\/li>\n<li> <strong>FUNCTION\uff1a<\/strong>\u6307\u5b9a\u8981\u521b\u5efa\u51fd\u6570\u7d22\u5f15\u3002<\/li>\n<\/ul>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>CREATE INDEX idx_product_name ON products (product_name) UNIQUE;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u8bed\u53e5\u5c06\u4e3a &#8220;product_name&#8221; \u5217\u521b\u5efa\u552f\u4e00 B-Tree \u7d22\u5f15\u3002<\/p>\n<p><strong>\u6ce8\u610f\u4e8b\u9879\uff1a<\/strong><\/p>\n<ul>\n<li> <strong>\u5f71\u54cd\u6027\u80fd\uff1a<\/strong>\u7d22\u5f15\u53ef\u4ee5\u52a0\u5feb\u68c0\u7d22\u901f\u5ea6\uff0c\u4f46\u4e5f\u4f1a\u5f71\u54cd\u63d2\u5165\u3001\u66f4\u65b0\u548c\u5220\u9664\u64cd\u4f5c\u7684\u6027\u80fd\u3002<\/li>\n<li> <strong>\u7ef4\u62a4\u5f00\u9500\uff1a<\/strong>\u5728\u6570\u636e\u66f4\u6539\u65f6\uff0c\u7d22\u5f15\u9700\u8981\u8fdb\u884c\u7ef4\u62a4\u3002\u8fd9\u53ef\u80fd\u4f1a\u5f71\u54cd\u6027\u80fd\u3002<\/li>\n<li> <strong>\u7a7a\u95f4\u9700\u6c42\uff1a<\/strong>\u7d22\u5f15\u4f1a\u5360\u7528\u6570\u636e\u5e93\u7a7a\u95f4\u3002<\/li>\n<li> <strong>\u9009\u62e9\u6027\uff1a<\/strong>\u7d22\u5f15\u7684\u6548\u7387\u53d6\u51b3\u4e8e\u5217\u503c\u7684\u552f\u4e00\u6027\u3002\u552f\u4e00\u6027\u8f83\u4f4e\u7684\u5217\u4f1a\u5bfc\u81f4\u8f83\u6162\u7684\u67e5\u8be2\u6027\u80fd\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u521b\u5efa\u7d22\u5f15\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\u521b\u5efa\u7d22\u5f15\u9700\u9075\u5faa\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u786e\u5b9a\u8868\u548c\u7d22\u5f15\u5217\u3002\u4f7f\u7528 create index \u8bed\u53e5\uff0c\u6307\u5b9a\u7d22\u5f15\u540d\u79f0\u3001\u8868\u540d\u79f0\u548c\u5217\u540d\u79f0\u3002\u6307\u5b9a\u7d22\u5f15\u7c7b\u578b\uff08\u9ed8\u8ba4 b-tree\uff09\uff0c\u5e76\u53ef\u6dfb\u52a0 unique\u3001primary key \u7b49\u9009\u9879\u3002\u6ce8\u610f\u4e8b\u9879\u5305\u62ec\u6027\u80fd\u5f71\u54cd\u3001\u7ef4\u62a4\u5f00\u9500\u3001\u7a7a\u95f4\u9700\u6c42\u548c\u9009\u62e9\u6027\u3002 \u4f7f\u7528 Oracle \u521b\u5efa\u7d22\u5f15 \u7d22\u5f15\u662f\u4e00\u79cd\u6570\u636e\u5e93\u5bf9\u8c61\uff0c\u7528\u4e8e\u52a0\u5feb\u5bf9\u8868\u4e2d\u6570\u636e\u7684\u68c0\u7d22\u901f\u5ea6\u3002\u5728 Oracle \u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u521b\u5efa\u7d22\u5f15\uff1a 1. \u786e\u5b9a\u8981\u521b\u5efa\u7d22\u5f15\u7684\u8868\u548c\u5217 \u9996\u5148\uff0c\u786e\u5b9a\u8981\u4e3a\u5176\u521b\u5efa\u7d22\u5f15\u7684\u8868\u548c\u5217\u3002\u9009\u62e9\u90a3\u4e9b\u5728\u67e5\u8be2\u4e2d\u7ecf\u5e38\u4f7f\u7528\u6216\u52a0\u5165\u7684\u5217\u3002 2. \u4f7f\u7528 CREATE INDEX \u8bed\u53e5 \u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\u521b\u5efa\u7d22\u5f15\uff1a CREATE INDEX [\u7d22\u5f15\u540d\u79f0] ON [\u8868\u540d\u79f0] ([\u5217\u540d\u79f0]); \u767b\u5f55\u540e\u590d\u5236 \u4f8b\u5982\uff0c\u8981\u4e3a\u540d\u4e3a &#8220;products&#8221; \u7684\u8868\u4e2d\u7684 &#8220;product_name&#8221; \u5217\u521b\u5efa\u7d22\u5f15\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\uff1a CREATE INDEX idx_product_name ON products (product_name); \u767b\u5f55\u540e\u590d\u5236 3. \u6307\u5b9a\u7d22\u5f15\u7c7b\u578b Oracle \u652f\u6301\u591a\u79cd\u7d22\u5f15\u7c7b\u578b\uff0c\u5305\u62ec B-Tree \u7d22\u5f15\u3001\u4f4d\u56fe\u7d22\u5f15\u548c\u51fd\u6570\u7d22\u5f15\u3002\u5982\u679c\u672a\u6307\u5b9a\u7d22\u5f15\u7c7b\u578b\uff0cOracle \u5c06\u9ed8\u8ba4\u521b\u5efa B-Tree \u7d22\u5f15\u3002 4. \u6307\u5b9a\u5176\u4ed6\u9009\u9879 \u521b\u5efa\u7d22\u5f15\u65f6\uff0c\u53ef\u4ee5\u6307\u5b9a\u4ee5\u4e0b\u9644\u52a0\u9009\u9879\uff1a [&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-6069","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6069","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=6069"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6069\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6069"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6069"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6069"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}