{"id":6106,"date":"2024-11-14T08:39:47","date_gmt":"2024-11-14T00:39:47","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6106\/"},"modified":"2024-11-14T08:39:47","modified_gmt":"2024-11-14T00:39:47","slug":"oracle%e5%a6%82%e4%bd%95%e5%88%9b%e5%bb%ba%e4%b8%bb%e9%94%ae%e7%ba%a6%e6%9d%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6106\/","title":{"rendered":"oracle\u5982\u4f55\u521b\u5efa\u4e3b\u952e\u7ea6\u675f"},"content":{"rendered":"<blockquote><p>\n  \u4e3b\u952e\u662f\u552f\u4e00\u6807\u8bc6\u8868\u4e2d\u6bcf\u4e00\u884c\u7684\u7279\u6b8a\u5217\u6216\u5217\u7ec4\u5408\uff0c\u5b83\u786e\u4fdd\u8868\u4e2d\u7684\u8bb0\u5f55\u90fd\u662f\u72ec\u4e00\u65e0\u4e8c\u7684\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u521b\u5efa\uff1a\u4f7f\u7528 alter table \u8bed\u53e5\u6307\u5b9a\u8868\u540d\u3002\u6dfb\u52a0 primary key \u5173\u952e\u5b57\u540e\u8ddf\u8981\u6307\u5b9a\u4e3a\u4e3b\u952e\u7684\u5217\u540d\u3002\u4e3b\u952e\u7ea6\u675f\u6709\u52a9\u4e8e\u786e\u4fdd\u6570\u636e\u552f\u4e00\u6027\u3001\u63d0\u9ad8\u67e5\u8be2\u901f\u5ea6\u3001\u9632\u6b62\u91cd\u590d\u8bb0\u5f55\u5e76\u7b80\u5316\u8868\u8fde\u63a5\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/12\/2024061223302388537.jpg\" class=\"aligncenter\" title=\"oracle\u5982\u4f55\u521b\u5efa\u4e3b\u952e\u7ea6\u675f\u63d2\u56fe\" alt=\"oracle\u5982\u4f55\u521b\u5efa\u4e3b\u952e\u7ea6\u675f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u4f7f\u7528 Oracle \u521b\u5efa\u4e3b\u952e\u7ea6\u675f<\/strong><\/p>\n<p><strong>\u4e3b\u952e\u7684\u4f5c\u7528<\/strong><\/p>\n<p>\u4e3b\u952e\u662f\u552f\u4e00\u6807\u8bc6\u8868\u4e2d\u6bcf\u4e00\u884c\u7684\u7279\u6b8a\u5217\u6216\u5217\u7ec4\u5408\u3002\u5b83\u786e\u4fdd\u8868\u4e2d\u7684\u6bcf\u4e2a\u8bb0\u5f55\u90fd\u662f\u72ec\u4e00\u65e0\u4e8c\u7684\uff0c\u5e76\u4e14\u53ef\u4ee5\u5feb\u901f\u6709\u6548\u5730\u67e5\u627e\u8bb0\u5f55\u3002<\/p>\n<p><strong>\u521b\u5efa\u4e3b\u952e\u7ea6\u675f\u7684\u8bed\u6cd5<\/strong><\/p>\n<pre>ALTER TABLE table_name ADD PRIMARY KEY (column_name1, column_name2, ...);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d\uff1a<\/p>\n<ul>\n<li>table_name \u662f\u8981\u521b\u5efa\u4e3b\u952e\u7ea6\u675f\u7684\u8868\u540d\u3002<\/li>\n<li>column_name1, column_name2, &#8230; \u662f\u8981\u6307\u5b9a\u4e3a\u4e3b\u952e\u7684\u5217\u3002<\/li>\n<\/ul>\n<p><strong>\u793a\u4f8b<\/strong><\/p>\n<p>\u8981\u4e3a\u540d\u4e3a employees \u7684\u8868\u521b\u5efa\u4e3b\u952e\u7ea6\u675f\uff0c\u4e3b\u952e\u5217\u4e3a employee_id\uff1a<\/p>\n<pre>ALTER TABLE employees ADD PRIMARY KEY (employee_id);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u4e3b\u952e\u7ea6\u675f\u7684\u597d\u5904<\/strong><\/p>\n<p>\u521b\u5efa\u4e3b\u952e\u7ea6\u675f\u5177\u6709\u4e00\u4e9b\u4e3b\u8981\u597d\u5904\uff1a<\/p>\n<ul>\n<li>\u786e\u4fdd\u8868\u4e2d\u7684\u6570\u636e\u552f\u4e00\u6027\u3002<\/li>\n<li>\u63d0\u9ad8\u6570\u636e\u67e5\u8be2\u548c\u68c0\u7d22\u901f\u5ea6\u3002<\/li>\n<li>\u9632\u6b62\u63d2\u5165\u91cd\u590d\u8bb0\u5f55\u3002<\/li>\n<li>\u7b80\u5316\u8868\u8fde\u63a5\u548c\u6570\u636e\u64cd\u7eb5\u64cd\u4f5c\u3002<\/li>\n<\/ul>\n<p><strong>\u6ce8\u610f\u4e8b\u9879<\/strong><\/p>\n<ul>\n<li>\u4e3b\u952e\u5217\u4e0d\u80fd\u4e3a NULL\u3002<\/li>\n<li>\u4e3b\u952e\u7ea6\u675f\u53ea\u80fd\u5e94\u7528\u4e8e\u5177\u6709\u552f\u4e00\u503c\u7684\u5217\u3002<\/li>\n<li>\u521b\u5efa\u4e3b\u952e\u7ea6\u675f\u540e\u65e0\u6cd5\u5220\u9664\u5b83\uff0c\u9664\u975e\u8868\u4e3a\u7a7a\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u521b\u5efa\u4e3b\u952e\u7ea6\u675f\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>\u4e3b\u952e\u662f\u552f\u4e00\u6807\u8bc6\u8868\u4e2d\u6bcf\u4e00\u884c\u7684\u7279\u6b8a\u5217\u6216\u5217\u7ec4\u5408\uff0c\u5b83\u786e\u4fdd\u8868\u4e2d\u7684\u8bb0\u5f55\u90fd\u662f\u72ec\u4e00\u65e0\u4e8c\u7684\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u521b\u5efa\uff1a\u4f7f\u7528 alter table \u8bed\u53e5\u6307\u5b9a\u8868\u540d\u3002\u6dfb\u52a0 primary key \u5173\u952e\u5b57\u540e\u8ddf\u8981\u6307\u5b9a\u4e3a\u4e3b\u952e\u7684\u5217\u540d\u3002\u4e3b\u952e\u7ea6\u675f\u6709\u52a9\u4e8e\u786e\u4fdd\u6570\u636e\u552f\u4e00\u6027\u3001\u63d0\u9ad8\u67e5\u8be2\u901f\u5ea6\u3001\u9632\u6b62\u91cd\u590d\u8bb0\u5f55\u5e76\u7b80\u5316\u8868\u8fde\u63a5\u3002 \u4f7f\u7528 Oracle \u521b\u5efa\u4e3b\u952e\u7ea6\u675f \u4e3b\u952e\u7684\u4f5c\u7528 \u4e3b\u952e\u662f\u552f\u4e00\u6807\u8bc6\u8868\u4e2d\u6bcf\u4e00\u884c\u7684\u7279\u6b8a\u5217\u6216\u5217\u7ec4\u5408\u3002\u5b83\u786e\u4fdd\u8868\u4e2d\u7684\u6bcf\u4e2a\u8bb0\u5f55\u90fd\u662f\u72ec\u4e00\u65e0\u4e8c\u7684\uff0c\u5e76\u4e14\u53ef\u4ee5\u5feb\u901f\u6709\u6548\u5730\u67e5\u627e\u8bb0\u5f55\u3002 \u521b\u5efa\u4e3b\u952e\u7ea6\u675f\u7684\u8bed\u6cd5 ALTER TABLE table_name ADD PRIMARY KEY (column_name1, column_name2, &#8230;); \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff1a table_name \u662f\u8981\u521b\u5efa\u4e3b\u952e\u7ea6\u675f\u7684\u8868\u540d\u3002 column_name1, column_name2, &#8230; \u662f\u8981\u6307\u5b9a\u4e3a\u4e3b\u952e\u7684\u5217\u3002 \u793a\u4f8b \u8981\u4e3a\u540d\u4e3a employees \u7684\u8868\u521b\u5efa\u4e3b\u952e\u7ea6\u675f\uff0c\u4e3b\u952e\u5217\u4e3a employee_id\uff1a ALTER TABLE employees ADD PRIMARY KEY (employee_id); \u767b\u5f55\u540e\u590d\u5236 \u4e3b\u952e\u7ea6\u675f\u7684\u597d\u5904 \u521b\u5efa\u4e3b\u952e\u7ea6\u675f\u5177\u6709\u4e00\u4e9b\u4e3b\u8981\u597d\u5904\uff1a \u786e\u4fdd\u8868\u4e2d\u7684\u6570\u636e\u552f\u4e00\u6027\u3002 \u63d0\u9ad8\u6570\u636e\u67e5\u8be2\u548c\u68c0\u7d22\u901f\u5ea6\u3002 \u9632\u6b62\u63d2\u5165\u91cd\u590d\u8bb0\u5f55\u3002 \u7b80\u5316\u8868\u8fde\u63a5\u548c\u6570\u636e\u64cd\u7eb5\u64cd\u4f5c\u3002 \u6ce8\u610f\u4e8b\u9879 \u4e3b\u952e\u5217\u4e0d\u80fd\u4e3a NULL\u3002 \u4e3b\u952e\u7ea6\u675f\u53ea\u80fd\u5e94\u7528\u4e8e\u5177\u6709\u552f\u4e00\u503c\u7684\u5217\u3002 \u521b\u5efa\u4e3b\u952e\u7ea6\u675f\u540e\u65e0\u6cd5\u5220\u9664\u5b83\uff0c\u9664\u975e\u8868\u4e3a\u7a7a\u3002 \u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u521b\u5efa\u4e3b\u952e\u7ea6\u675f\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},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-6106","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6106","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=6106"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6106\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}