{"id":5739,"date":"2024-11-14T09:39:58","date_gmt":"2024-11-14T01:39:58","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5739\/"},"modified":"2024-11-14T09:39:58","modified_gmt":"2024-11-14T01:39:58","slug":"oracle%e5%88%9b%e5%bb%ba%e8%a1%a8%e6%a0%bc%e6%80%8e%e4%b9%88%e5%86%99","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5739\/","title":{"rendered":"oracle\u521b\u5efa\u8868\u683c\u600e\u4e48\u5199"},"content":{"rendered":"<blockquote><p>\n  \u5728 oracle \u4e2d\u521b\u5efa\u8868\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\uff1a1. \u4f7f\u7528 create table \u8bed\u53e5\u30022. \u5b9a\u4e49\u8868\u540d\u30023. \u6307\u5b9a\u5217\u53ca\u5176\u6570\u636e\u7c7b\u578b\u3001\u7ea6\u675f\uff08\u5982 not null\u3001unique\uff09\u30024. \u5b9a\u4e49\u4e3b\u952e\uff08\u53ef\u9009\uff09\u30025. \u6dfb\u52a0\u7ea6\u675f\uff08\u5982\u5916\u952e\u3001\u68c0\u67e5\u7ea6\u675f\uff09\uff08\u53ef\u9009\uff09\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/30\/2024053021455369538.jpg\" class=\"aligncenter\" title=\"oracle\u521b\u5efa\u8868\u683c\u600e\u4e48\u5199\u63d2\u56fe\" alt=\"oracle\u521b\u5efa\u8868\u683c\u600e\u4e48\u5199\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5728 Oracle \u4e2d\u521b\u5efa\u8868<\/strong><\/p>\n<p>\u5728 Oracle \u6570\u636e\u5e93\u4e2d\u521b\u5efa\u8868\u662f\u5b58\u50a8\u548c\u7ba1\u7406\u6570\u636e\u7684\u57fa\u672c\u64cd\u4f5c\u3002\u8981\u521b\u5efa\u8868\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\uff1a<\/p>\n<p><strong>1. \u4f7f\u7528 CREATE TABLE \u8bed\u53e5<\/strong><\/p>\n<pre>CREATE TABLE &lt;\u8868\u540d&gt; (\n  &lt;\u5217\u540d_1&gt; &lt;\u6570\u636e\u7c7b\u578b&gt; [NOT NULL] [UNIQUE],\n  &lt;\u5217\u540d_2&gt; &lt;\u6570\u636e\u7c7b\u578b&gt; [NOT NULL] [UNIQUE],\n  ...\n  &lt;\u5217\u540d_n&gt; &lt;\u6570\u636e\u7c7b\u578b&gt; [NOT NULL] [UNIQUE]\n);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. \u5b9a\u4e49\u8868\u540d<\/strong><\/p>\n<p> \u662f\u8981\u521b\u5efa\u7684\u65b0\u8868\u7684\u540d\u79f0\u3002<\/p>\n<p><strong>3. \u6307\u5b9a\u5217<\/strong><\/p>\n<ul>\n<li>\uff1a\u5217\u7684\u540d\u79f0\u3002<\/li>\n<li>\uff1a\u5217\u7684\u6570\u636e\u7c7b\u578b\uff08\u4f8b\u5982 VARCHAR2\u3001NUMBER\u3001DATE \u7b49\uff09\u3002<\/li>\n<li>NOT NULL\uff1a\u6307\u5b9a\u5217\u4e0d\u80fd\u4e3a\u7a7a\u3002<\/li>\n<li>UNIQUE\uff1a\u6307\u5b9a\u5217\u4e2d\u7684\u503c\u5fc5\u987b\u552f\u4e00\u3002<\/li>\n<\/ul>\n<p><strong>4. \u5b9a\u4e49\u4e3b\u952e<\/strong><\/p>\n<p>\u53ef\u4ee5\u5c06\u4e00\u4e2a\u6216\u591a\u4e2a\u5217\u6307\u5b9a\u4e3a\u4e3b\u952e\uff0c\u4ee5\u552f\u4e00\u6807\u8bc6\u8868\u4e2d\u7684\u6bcf\u4e00\u884c\u3002\u8981\u5b9a\u4e49\u4e3b\u952e\uff0c\u53ef\u4ee5\u5728\u5217\u5b9a\u4e49\u4e2d\u6dfb\u52a0 PRIMARY KEY \u7ea6\u675f\u3002<\/p>\n<pre>CREATE TABLE &lt;\u8868\u540d&gt; (\n  &lt;\u5217\u540d_1&gt; &lt;\u6570\u636e\u7c7b\u578b&gt; PRIMARY KEY,\n  ...\n);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>5. \u6dfb\u52a0\u7ea6\u675f<\/strong><\/p>\n<p>\u7ea6\u675f\u7528\u4e8e\u5f3a\u5236\u6267\u884c\u6570\u636e\u5b8c\u6574\u6027\u89c4\u5219\u3002\u9664\u4e86 NOT NULL \u548c UNIQUE \u7ea6\u675f\u5916\uff0c\u8fd8\u53ef\u4ee5\u6dfb\u52a0\u5176\u4ed6\u7ea6\u675f\uff0c\u4f8b\u5982\u5916\u952e\u3001\u68c0\u67e5\u7ea6\u675f\u7b49\u3002<\/p>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<p>\u8981\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a customers \u7684\u8868\uff0c\u5176\u4e2d\u5305\u542b customer_id\uff08\u4e3b\u952e\uff09\u3001name \u548c address \u5217\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\uff1a<\/p>\n<pre>CREATE TABLE customers (\n  customer_id NUMBER PRIMARY KEY,\n  name VARCHAR2(50) NOT NULL,\n  address VARCHAR2(255)\n);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6ce8\u610f\uff1a<\/strong><\/p>\n<ul>\n<li>\u8868\u540d\u548c\u5217\u540d\u5bf9\u5927\u5c0f\u5199\u4e0d\u654f\u611f\u3002<\/li>\n<li>NOT NULL \u7ea6\u675f\u53ef\u786e\u4fdd\u5217\u4e2d\u4e0d\u80fd\u5305\u542b\u7a7a\u503c\u3002<\/li>\n<li>UNIQUE \u7ea6\u675f\u53ef\u786e\u4fdd\u5217\u4e2d\u7684\u503c\u552f\u4e00\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u521b\u5efa\u8868\u683c\u600e\u4e48\u5199\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>\u5728 oracle \u4e2d\u521b\u5efa\u8868\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\uff1a1. \u4f7f\u7528 create table \u8bed\u53e5\u30022. \u5b9a\u4e49\u8868\u540d\u30023. \u6307\u5b9a\u5217\u53ca\u5176\u6570\u636e\u7c7b\u578b\u3001\u7ea6\u675f\uff08\u5982 not null\u3001unique\uff09\u30024. \u5b9a\u4e49\u4e3b\u952e\uff08\u53ef\u9009\uff09\u30025. \u6dfb\u52a0\u7ea6\u675f\uff08\u5982\u5916\u952e\u3001\u68c0\u67e5\u7ea6\u675f\uff09\uff08\u53ef\u9009\uff09\u3002 \u5728 Oracle \u4e2d\u521b\u5efa\u8868 \u5728 Oracle \u6570\u636e\u5e93\u4e2d\u521b\u5efa\u8868\u662f\u5b58\u50a8\u548c\u7ba1\u7406\u6570\u636e\u7684\u57fa\u672c\u64cd\u4f5c\u3002\u8981\u521b\u5efa\u8868\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\uff1a 1. \u4f7f\u7528 CREATE TABLE \u8bed\u53e5 CREATE TABLE &lt;\u8868\u540d&gt; ( &lt;\u5217\u540d_1&gt; &lt;\u6570\u636e\u7c7b\u578b&gt; [NOT NULL] [UNIQUE], &lt;\u5217\u540d_2&gt; &lt;\u6570\u636e\u7c7b\u578b&gt; [NOT NULL] [UNIQUE], &#8230; &lt;\u5217\u540d_n&gt; &lt;\u6570\u636e\u7c7b\u578b&gt; [NOT NULL] [UNIQUE] ); \u767b\u5f55\u540e\u590d\u5236 2. \u5b9a\u4e49\u8868\u540d \u662f\u8981\u521b\u5efa\u7684\u65b0\u8868\u7684\u540d\u79f0\u3002 3. \u6307\u5b9a\u5217 \uff1a\u5217\u7684\u540d\u79f0\u3002 \uff1a\u5217\u7684\u6570\u636e\u7c7b\u578b\uff08\u4f8b\u5982 VARCHAR2\u3001NUMBER\u3001DATE \u7b49\uff09\u3002 [&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-5739","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5739","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=5739"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5739\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5739"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5739"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5739"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}