{"id":199990,"date":"2025-05-06T11:33:14","date_gmt":"2025-05-06T03:33:14","guid":{"rendered":"https:\/\/server.hk\/cnblog\/199990\/"},"modified":"2025-05-06T11:33:14","modified_gmt":"2025-05-06T03:33:14","slug":"%e6%b7%b1%e5%85%a5%e7%a0%94%e7%a9%b6oracle%e6%95%b0%e6%8d%ae%e5%ba%93%e4%b8%ad%e5%90%84%e7%a7%8d%e7%b4%a2%e5%bc%95%e7%b1%bb%e5%9e%8b%e5%8f%8a%e5%85%b6%e4%bd%bf%e7%94%a8%e6%83%85%e5%86%b5","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/199990\/","title":{"rendered":"\u6df1\u5165\u7814\u7a76Oracle\u6570\u636e\u5e93\u4e2d\u5404\u79cd\u7d22\u5f15\u7c7b\u578b\u53ca\u5176\u4f7f\u7528\u60c5\u51b5"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u6df1\u5165\u7814\u7a76Oracle\u6570\u636e\u5e93\u4e2d\u5404\u79cd\u7d22\u5f15\u7c7b\u578b\u53ca\u5176\u4f7f\u7528\u60c5\u51b5<\/h1>\n<p>\u5c0f\u4f19\u4f34\u4eec\u6709\u6ca1\u6709\u89c9\u5f97\u5b66\u4e60\u5f88\u6709\u610f\u601d\uff1f\u6709\u610f\u601d\u5c31\u5bf9\u4e86\uff01\u4eca\u5929\u5c31\u7ed9\u5927\u5bb6\u5e26\u6765\uff0c\u4ee5\u4e0b\u5185\u5bb9\u5c06\u4f1a\u6d89\u53ca\u5230\uff0c\u82e5\u662f\u5728\u5b66\u4e60\u4e2d\u5bf9\u5176\u4e2d\u90e8\u5206\u77e5\u8bc6\u70b9\u6709\u7591\u95ee\uff0c\u6216\u8bb8\u770b\u4e86\u672c\u6587\u5c31\u80fd\u5e2e\u5230\u4f60\uff01<\/p>\n<p>\u6df1\u5165\u4e86\u89e3Oracle\u6570\u636e\u5e93\u4e2d\u7684\u4e0d\u540c\u7d22\u5f15\u53ca\u5176\u5e94\u7528\u573a\u666f<\/p>\n<p>\u5728Oracle\u6570\u636e\u5e93\u4e2d\uff0c\u7d22\u5f15\u662f\u4e00\u79cd\u5b58\u50a8\u5728\u8868\u4e2d\u7684\u6570\u636e\u7ed3\u6784\uff0c\u7528\u4e8e\u52a0\u5feb\u5bf9\u8868\u4e2d\u6570\u636e\u7684\u8bbf\u95ee\u901f\u5ea6\u3002\u901a\u8fc7\u521b\u5efa\u9002\u5f53\u7684\u7d22\u5f15\uff0c\u53ef\u4ee5\u63d0\u9ad8\u67e5\u8be2\u7684\u6548\u7387\uff0c\u964d\u4f4e\u6570\u636e\u5e93\u7684\u8d1f\u8f7d\uff0c\u52a0\u5feb\u6570\u636e\u7684\u68c0\u7d22\u901f\u5ea6\u3002\u4e0d\u540c\u7c7b\u578b\u7684\u7d22\u5f15\u53ef\u6839\u636e\u5b9e\u9645\u9700\u6c42\u9009\u62e9\u4f7f\u7528\uff0c\u4ee5\u8fbe\u5230\u6700\u4f73\u7684\u6027\u80fd\u4f18\u5316\u6548\u679c\u3002<\/p>\n<ol>\n<li>\n<p>B\u6811\u7d22\u5f15<br \/>B\u6811\u7d22\u5f15\u662f\u6700\u5e38\u89c1\u7684\u7d22\u5f15\u7c7b\u578b\uff0c\u9002\u7528\u4e8e\u7b49\u503c\u548c\u8303\u56f4\u67e5\u8be2\u3002\u5728Oracle\u6570\u636e\u5e93\u4e2d\uff0c\u521b\u5efaB\u6811\u7d22\u5f15\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0bSQL\u8bed\u53e5\uff1a<\/p>\n<pre>CREATE INDEX index_name ON table_name (column_name);<\/pre>\n<p>\u5176\u4e2d\uff0cindex_name\u4e3a\u7d22\u5f15\u540d\uff0ctable_name\u4e3a\u8868\u540d\uff0ccolumn_name\u4e3a\u5217\u540d\u3002\u4f8b\u5982\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3aidx_emp_id\u7684B\u6811\u7d22\u5f15\uff1a<\/p>\n<pre>CREATE INDEX idx_emp_id ON employees (employee_id);<\/pre>\n<\/li>\n<li>\n<p>\u552f\u4e00\u7d22\u5f15<br \/>\u552f\u4e00\u7d22\u5f15\u662f\u4e00\u79cd\u4fdd\u8bc1\u5217\u503c\u7684\u552f\u4e00\u6027\u7684\u7d22\u5f15\uff0c\u9002\u7528\u4e8e\u9700\u8981\u4fdd\u8bc1\u6570\u636e\u5b8c\u6574\u6027\u7684\u573a\u666f\u3002\u5728Oracle\u6570\u636e\u5e93\u4e2d\uff0c\u521b\u5efa\u552f\u4e00\u7d22\u5f15\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0bSQL\u8bed\u53e5\uff1a<\/p>\n<pre>CREATE UNIQUE INDEX index_name ON table_name (column_name);<\/pre>\n<p>\u4f8b\u5982\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3aidx_emp_email\u7684\u552f\u4e00\u7d22\u5f15\uff1a<\/p>\n<pre>CREATE UNIQUE INDEX idx_emp_email ON employees (email);<\/pre>\n<\/li>\n<li>\n<p>\u805a\u96c6\u7d22\u5f15<br \/>\u805a\u96c6\u7d22\u5f15\u662f\u6309\u7167\u8868\u7684\u7269\u7406\u987a\u5e8f\u5b58\u50a8\u6570\u636e\u7684\u7d22\u5f15\uff0c\u901a\u5e38\u4e0e\u4e3b\u952e\u7ea6\u675f\u76f8\u5173\u8054\u3002\u5728Oracle\u6570\u636e\u5e93\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u521b\u5efa\u4e3b\u952e\u7ea6\u675f\u6765\u5b9e\u73b0\u805a\u96c6\u7d22\u5f15\uff1a<\/p>\n<pre>ALTER TABLE table_name ADD CONSTRAINT pk_constraint PRIMARY KEY (column_name);<\/pre>\n<p>\u4f8b\u5982\uff0c\u4e3aemployees\u8868\u7684employee_id\u5217\u521b\u5efa\u4e3b\u952e\u7ea6\u675f\uff1a<\/p>\n<pre>ALTER TABLE employees ADD CONSTRAINT pk_emp_id PRIMARY KEY (employee_id);<\/pre>\n<\/li>\n<li>\n<p>\u590d\u5408\u7d22\u5f15<br \/>\u590d\u5408\u7d22\u5f15\u662f\u5305\u542b\u591a\u4e2a\u5217\u7684\u7d22\u5f15\uff0c\u9002\u7528\u4e8e\u9700\u8981\u6309\u7167\u591a\u4e2a\u5217\u8fdb\u884c\u68c0\u7d22\u7684\u573a\u666f\u3002\u5728Oracle\u6570\u636e\u5e93\u4e2d\uff0c\u521b\u5efa\u590d\u5408\u7d22\u5f15\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0bSQL\u8bed\u53e5\uff1a<\/p>\n<pre>CREATE INDEX index_name ON table_name (column1, column2);<\/pre>\n<p>\u4f8b\u5982\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3aidx_emp_name_dept\u7684\u590d\u5408\u7d22\u5f15\uff1a<\/p>\n<pre>CREATE INDEX idx_emp_name_dept ON employees (employee_name, department_id);<\/pre>\n<\/li>\n<li>\n<p>\u5168\u6587\u7d22\u5f15<br \/>\u5168\u6587\u7d22\u5f15\u662f\u7528\u4e8e\u641c\u7d22\u6587\u672c\u6570\u636e\u7684\u7d22\u5f15\uff0c\u9002\u7528\u4e8e\u9700\u8981\u8fdb\u884c\u5168\u6587\u641c\u7d22\u7684\u573a\u666f\u3002\u5728Oracle\u6570\u636e\u5e93\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528Oracle Text\u7ec4\u4ef6\u6765\u521b\u5efa\u5168\u6587\u7d22\u5f15\uff1a<\/p>\n<pre>CREATE INDEX index_name ON table_name (column_name) INDEXTYPE IS CTXSYS.CONTEXT;<\/pre>\n<p>\u4f8b\u5982\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3aidx_product_desc\u7684\u5168\u6587\u7d22\u5f15\uff1a<\/p>\n<pre>CREATE INDEX idx_product_desc ON products (product_description) INDEXTYPE IS CTXSYS.CONTEXT;<\/pre>\n<\/li>\n<\/ol>\n<p>\u603b\u7ed3<br \/>\u4e0d\u540c\u7c7b\u578b\u7684\u7d22\u5f15\u5728Oracle\u6570\u636e\u5e93\u4e2d\u6709\u7740\u5404\u81ea\u7684\u5e94\u7528\u573a\u666f\u548c\u4f18\u52bf\u3002\u901a\u8fc7\u7075\u6d3b\u9009\u62e9\u9002\u5408\u7684\u7d22\u5f15\u7c7b\u578b\uff0c\u5e76\u7ed3\u5408\u5b9e\u9645\u9700\u6c42\u8fdb\u884c\u4f18\u5316\u548c\u8c03\u6574\uff0c\u53ef\u4ee5\u6709\u6548\u63d0\u5347\u6570\u636e\u5e93\u7684\u6027\u80fd\u548c\u67e5\u8be2\u6548\u7387\u3002\u56e0\u6b64\uff0c\u5728\u8bbe\u8ba1\u6570\u636e\u5e93\u8868\u7ed3\u6784\u65f6\uff0c\u9700\u7efc\u5408\u8003\u8651\u7d22\u5f15\u7684\u521b\u5efa\u548c\u4f7f\u7528\uff0c\u4ee5\u8fbe\u5230\u6700\u4f73\u7684\u6027\u80fd\u4f18\u5316\u6548\u679c\u3002<\/p>\n<p>\u7ec8\u4e8e\u4ecb\u7ecd\u5b8c\u5566\uff01\u5c0f\u4f19\u4f34\u4eec\uff0c\u8fd9\u7bc7\u5173\u4e8e\u300a\u6df1\u5165\u7814\u7a76Oracle\u6570\u636e\u5e93\u4e2d\u5404\u79cd\u7d22\u5f15\u7c7b\u578b\u53ca\u5176\u4f7f\u7528\u60c5\u51b5\u300b\u7684\u4ecb\u7ecd\u5e94\u8be5\u8ba9\u4f60\u6536\u83b7\u591a\u591a\u4e86\u5427\uff01\u6b22\u8fce\u5927\u5bb6\u6536\u85cf\u6216\u5206\u4eab\u7ed9\u66f4\u591a\u9700\u8981\u5b66\u4e60\u7684\u670b\u53cb\u5427~\u4e3b\u673a\u5b9d\u8d1d\u516c\u4f17\u53f7\u4e5f\u4f1a\u53d1\u5e03\u6570\u636e\u5e93\u76f8\u5173\u77e5\u8bc6\uff0c\u5feb\u6765\u5173\u6ce8\u5427\uff01<\/p>\n<dl>\n<dt>\n <\/dt>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u6df1\u5165\u7814\u7a76Oracle\u6570\u636e\u5e93\u4e2d\u5404\u79cd&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-199990","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199990","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=199990"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199990\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=199990"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=199990"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=199990"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}