{"id":83,"date":"2025-03-21T14:14:15","date_gmt":"2025-03-21T06:14:15","guid":{"rendered":"https:\/\/zd1269878.noblogs.org\/?p=83"},"modified":"2025-10-21T10:32:43","modified_gmt":"2025-10-21T02:32:43","slug":"2025-03-21-%e6%95%b0%e6%8d%ae%e5%ba%93-%e7%ac%94%e8%ae%b0%e6%95%b4%e7%90%86","status":"publish","type":"post","link":"https:\/\/zd1269878.noblogs.org\/en-US\/post\/2025\/03\/21\/2025-03-21-%e6%95%b0%e6%8d%ae%e5%ba%93-%e7%ac%94%e8%ae%b0%e6%95%b4%e7%90%86\/","title":{"rendered":"2025-03-21-\u6570\u636e\u5e93-\u7b14\u8bb0\u6574\u7406"},"content":{"rendered":"<p>SQL\u5206\u7c7b<br \/>\n\u00b7\u6570\u636e\u5b9a\u4e49\u8bed\u8a00 DDL \uff08Data Definition Language\uff09\u5927\u5e45\u5ea6<br \/>\n\u00b7\u7528\u4e8e\u521b\u5efa\u3001\u66f4\u6539\u6216\u5220\u9664\u6570\u636e\u5e93\u5bf9\u8c61\uff0c\u5982\u8868\u3001\u89c6\u56fe\u3001\u7d22\u5f15\u53ca\u5176<br \/>\n\u5b83\u5bf9\u8c61\u3002<br \/>\n\u00b7\u8bed\u53e5\u5305\u62ec\uff1a***<u>CREATE\u3001ALTER\u3001DROP<\/u>***\u00b7<br \/>\n\u6570\u636e\u64cd\u7eb5\u8bed\u8a00DML\uff08Data Manipulation Language\uff09\u5c0f\u5e45\u5ea6<br \/>\n\u25a0\u7528\u4e8e\u64cd\u7eb5\u6570\u636e\u5e93\u5bf9\u8c61\u3002<br \/>\n\u00b7\u8bed\u53e5\u5305\u62ec\uff1aSELECT\u3001INSERT\u3001UPDATE\u3001DELETE<br \/>\n\u00b7\u6570\u636e\u63a7\u5236\u8bed\u8a00DCL \uff08Data Control Language\uff09<br \/>\n\u00b7\u7528\u4e8e\u5b9a\u4e49\u63a7\u5236\u8bbf\u95ee\u5bf9\u8c61\u3002<br \/>\n\u00b7\u8bed\u53e5\u5305\u62ec\uff1aGRANT\u3001REVOKE<br \/>\n<strong><em>\u6570\u636e\u7c7b\u578b<\/em><\/strong><\/p>\n<p><strong><em>\u5b57\u7b26\u578b<\/em><\/strong><br \/>\n\u00b7Char\uff08n\uff09\uff1a\u56fa\u5b9a\u957f\u5ea6\u7684\u5b57\u7b26\u4e32 **\u7a7a\u7684\u81ea\u52a8\u7f6e\u7a7a**<br \/>\n\u00b7Varchar\uff08n\uff09\uff1a\u53ef\u53d8\u957f\u5b57\u7b26\u4e32 **\u6765\u51e0\u4e2a\u5360\u51e0\u4e2a**<br \/>\n<strong>\u00b7\u6570\u503c\u578b<\/strong><br \/>\n\u00b7<strong><em>\u6574\u6570\u578b<\/em><\/strong><br \/>\n\u00b7bigint\uff1a8\u5b57\u8282\u3001int\uff1a4\u5b57\u8282\u3001smallint\uff1a2\u5b57\u8282\u3001tinyint\uff1a1\u5b57\u8282<br \/>\n<strong>\u00b7<em>\u5c0f\u6570\u578b<\/em><\/strong><br \/>\nnumeric\uff08p,s\uff09\uff1a\u5b9a\u70b9\u6570\uff0c\u6574\u6570\u4f4d\u548c\u5c0f\u6570\u4f4d\u5171p\u4f4d\uff0c\u5c0f\u6570\u4f4ds\u4f4d\uff0c **10\uff0c2\u6574\u6570\u516b\u4f4d**<br \/>\n0&lt;=s&lt;=p&lt;=38<br \/>\n\u00b7 decimal\uff0c\u7528\u6cd5\u540cnumeric<br \/>\n\u00b7<u>**\u8d27\u5e01\u578b**<\/u><br \/>\n\u00b7 money\u3001smallmoney<br \/>\n<strong>\u65e5\u671f\u578b<\/strong><br \/>\n\u00b7datetime\uff1a\u7cbe\u786e\u5ea61\/300\u79d2\uff0c8\u5b57\u8282 ***\u8ba1\u7b97\u65b9\u6cd5:\u5f53\u524d\u65f6\u95f4-(1899-1-1-0:0\uff09***<br \/>\n\u00b7Smalldatetime\uff1a\u8303\u56f4\u7f29\u5c0f\uff0c\u7cbe\u786e\u5ea61\u79d2\uff0c4\u5b57\u8282<\/p>\n<p>\u521b\u5efa\u8868<br \/>\n\u00b7\u8bbe\u8ba1\u8868\u7684\u7ed3\u6784\uff1a<br \/>\n\u00b7\u5b57\u6bb5\u7684\u540d\u79f0<br \/>\n\u00b7\u6bcf\u4e2a\u5b57\u6bb5\u7684\u6570\u636e\u7c7b\u578b\u548c\u5bbd\u5ea6<br \/>\n\u00b7\u5b57\u6bb5\u662f\u5426\u5141\u8bb8\u4e3a\u7a7a<br \/>\n\u00b7\u662f\u5426\u6709\u7f3a\u7701\u503c<br \/>\n\u00b7\u662f\u5426\u4e3a\u6807\u8bc6\u5217<br \/>\n\u00b7\u662f\u5426\u4e3a\u4e3b\u952e\u3001\u5916\u952e<\/p>\n<p>\u8bed\u6cd51\uff1a<br \/>\n<code>    CREATE TABLE<br \/>\n\uff08[NULLI NOT NULL],<br \/>\n[PRIMARY KEY\uff0c]<br \/>\n[FOREIGN KEY  REFERENCES &lt;\u5916\u6765\u5173\u952e\u5b57\u6240<br \/>\n[CHECK\uff0c]\uff09;<br \/>\n\u4f8b1.\u5efa\u7acbstudent\u5173\u7cfb<br \/>\nCREATE TABLE student\uff08<br \/>\nsno char(8) NOT NULL,<br \/>\nsname varchar(2o) NoT NULL,<br \/>\nage numeric(3,0),<br \/>\nsex char(2),<br \/>\ndeptno char(6));<\/code><\/p>\n<p>\u5efa\u8868\u8fc7\u7a0b<\/p>\n<p><code>create table student<br \/>\n(<br \/>\nsno    CHAR(8)      not null Unique(\u4ee3\u8868\u552f\u4e00),<br \/>\nsname  VARCHAR2(20) not null default('\u7f3a\u7701\u503c'),<br \/>\nage    NUMBER(3),<br \/>\nsex    CHAR(2),<br \/>\ndeptno CHAR(6)<br \/>\n)<\/code><\/p>\n<p><code>tables\u4e0b\u67e5\u770b<br \/>\n\u8868\u4e0a\u53f3\u952e<br \/>\nView\u662f\u67e5\u770b\u8868\u7ed3\u6784<br \/>\nQurrey data\u67e5\u8be2\u6570\u636e<\/code><\/p>\n<p>UNIQUE\u4ee3\u8868\u552f\u4e00\u5217<br \/>\nDEFAULT('\u4ee3\u8868\u7f3a\u7701\u503c')<br \/>\n\u5217\u540d\u4e2d\u6700\u540e\u4e0d\u8981\u6709\u7a7a\u683c<br \/>\n<code>CREATE TABLE stu_girl AS<br \/>\nSELECT * FROM STUDENT t WHERE t.SEX='02';<\/code>t\u662f\u522b\u540d<br \/>\nDROP\u5220\u9664\u8868\u7ed3\u6784\u548c\u6570\u636e<br \/>\nDELETE\u53ea\u5220\u9664\u6570\u636e\u884c<\/p>\n<p>\u5b9e\u8df5\u8bfe\u8003\u5bdf\u4ee3\u7801<br \/>\n<code>create table student<br \/>\n(<br \/>\nSno    CHAR(7)      not null ,<br \/>\nSname  VARCHAR2(20) not null ,<br \/>\nSsex    CHAR(2) not null,<br \/>\nSbirth    DATE,<br \/>\nClno CHAR(5) not null<br \/>\n);<br \/>\nCREATE TABLE Course(<br \/>\nCno CHAR(3) NOT NULL,<br \/>\nCname VARCHAR2(20) NOT NULL,<br \/>\nCcredit SMALLINT,<br \/>\nCpno CHAR(3)<br \/>\n);<br \/>\nCREATE TABLE Class(<br \/>\nClno CHAR(5) NOT NULL,<br \/>\nSpecial VARCHAR2(20) NOT NULL,<br \/>\nInyear CHAR(4) NOT NULL,<br \/>\n\"NUMBER\" INTEGER,<br \/>\nMonitor CHAR(7)<br \/>\n);<br \/>\nCREATE TABLE Grade(<br \/>\nSno CHAR(7) NOT NULL,<br \/>\nCno CHAR(1) NOT NULL,<br \/>\nGmark NUMERIC(4,1)<br \/>\n);<\/p>\n<p><code>ADD ***\u6570\u636e\u5217\u540d*** \u6570\u636e\u7c7b\u578b #\u6dfb\u52a0\u65b0\u7684\u5217<br \/>\nDROP ***COLUMN*** \u5217\u540d #\u5220\u9664\u5217<br \/>\nALTER ***COLUMN*** \u5217\u540d \u65b0\u7684\u6570\u636e\u7c7b\u578b #\u6539\u8be5\u5217\u7684\u6570\u636e\u7c7b\u578b\uff0c\u53ea\u80fd\u52a0\u957f\u4e0d\u80fd\u7f29\u77ed<br \/>\nADD CONSTRAINT  \u7ea6\u675f\u540d \u5177\u4f53\u7ea6\u675f #\u6dfb\u52a0\u7ea6\u675f UNIQUE\u53ef\u4ee5\u4e3a\u7a7a\u4e0d\u80fd\u76f8\u540c PRIMARY\u4e0d\u80fd\u4e3a\u7a7a\u4e0d\u80fd\u76f8\u540c<\/code><\/p>\n<p>sql<br \/>\n<code>alter table STUDENT<br \/>\n    add constraint stu_pk #\u6dfb\u52a0\u952e<br \/>\n        primary key (SNO) #\u4e3b\u952e\uff0c\u5e94\u7528\u4e8eSNO\u5217<br \/>\n\/<\/code><br \/>\nsql<br \/>\n<code>INSERT #\u589e\u52a0<br \/>\nUPDATE #\u4fee\u6539<br \/>\nDELETE #\u5220\u9664<\/code><\/p>\n<p>sql<br \/>\n<code>INSERT INTO STUDENT (sno, sname, ssex, sbirth, clno) VALUES ('2020101', '\u674e\u52c7', '01', to_date('2002-08-09', 'YYYY-MM-DD'), '20311');\/*\u65f6\u95f4\u9700\u8981\u4f7f\u7528to_date()\u51fd\u6570*\/<br \/>\nINSERT INTO STUDENT (sno, sname, ssex, sbirth, clno) VALUES ('2020102', '\u5218\u8bd7\u6668', '02', to_date('2003-04-01', 'YYYY-MM-DD'), '20311');<br \/>\nINSERT INTO STUDENT (sno, sname, ssex, sbirth, clno) VALUES ('2020103', '\u738b\u4e00\u9e23', '01', to_date('2002-12-25', 'YYYY-MM-DD'), '20312');<br \/>\nINSERT INTO STUDENT (sno, sname, ssex, sbirth, clno) VALUES ('2020104', '\u5f20\u5a77\u5a77', '02', to_date('2002-10-01', 'YYYY-MM-DD'), '20312');<br \/>\nINSERT INTO STUDENT (sno, sname, ssex, sbirth, clno) VALUES ('2020105', '\u674e\u52c7\u654f', '02', to_date('2003-11-11', 'YYYY-MM-DD'), '21311');<br \/>\nINSERT INTO STUDENT (sno, sname, ssex, sbirth, clno) VALUES ('2020106', '\u8d3e\u5411\u4e1c', '02', to_date('2003-12-12', 'YYYY-MM-DD'), '21311');<br \/>\nINSERT INTO STUDENT VALUES ('2020107', '\u9648\u5b9d\u7389', '01', to_date('2004-05-01', 'YYYY-MM-DD'), '21311');\/*\u5f53\u63d2\u5165\u7684\u6570\u636e\u5168\u90e8\u6309\u7167\u987a\u5e8f\u65f6VALUES\u53ef\u4ee5\u7701\u7565*\/<br \/>\nINSERT INTO STUDENT VALUES ('2020108', '\u5f20\u9038\u51e1', '01', to_date('2005-01-01', 'YYYY-MM-DD'), '21311');<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>SQL\u5206\u7c7b \u00b7\u6570\u636e\u5b9a\u4e49\u8bed\u8a00 DDL \uff08Data Definition Language\uff09\u5927\u5e45\u5ea6 \u00b7\u7528\u4e8e\u521b\u5efa\u3001\u66f4\u6539\u6216\u5220\u9664\u6570\u636e\u5e93\u5bf9\u8c61\uff0c\u5982\u8868\u3001\u89c6\u56fe\u3001\u7d22\u5f15\u53ca\u5176 \u5b83\u5bf9\u8c61\u3002 \u00b7\u8bed\u53e5\u5305\u62ec\uff1a***CREATE\u3001ALTER\u3001DROP***\u00b7 \u6570\u636e\u64cd\u7eb5\u8bed\u8a00DML\uff08Data Manipulation Language\uff09\u5c0f\u5e45\u5ea6 \u25a0\u7528\u4e8e\u64cd\u7eb5\u6570\u636e\u5e93\u5bf9\u8c61\u3002 \u00b7\u8bed\u53e5\u5305\u62ec\uff1aSELECT\u3001INSERT\u3001UPDATE\u3001DELETE \u00b7\u6570\u636e\u63a7\u5236\u8bed\u8a00DCL \uff08Data Control Language\uff09 \u00b7\u7528\u4e8e\u5b9a\u4e49\u63a7\u5236\u8bbf\u95ee\u5bf9\u8c61\u3002 \u00b7\u8bed\u53e5\u5305\u62ec\uff1aGRANT\u3001REVOKE \u6570\u636e\u7c7b\u578b \u5b57\u7b26\u578b \u00b7Char\uff08n\uff09\uff1a\u56fa\u5b9a\u957f\u5ea6\u7684\u5b57\u7b26\u4e32 **\u7a7a\u7684\u81ea\u52a8\u7f6e\u7a7a** \u00b7Varchar\uff08n\uff09\uff1a\u53ef\u53d8\u957f\u5b57\u7b26\u4e32 **\u6765\u51e0\u4e2a\u5360\u51e0\u4e2a** \u00b7\u6570\u503c\u578b \u00b7\u6574\u6570\u578b \u00b7bigint\uff1a8\u5b57\u8282\u3001int\uff1a4\u5b57\u8282\u3001smallint\uff1a2\u5b57\u8282\u3001tinyint\uff1a1\u5b57\u8282 \u00b7\u5c0f\u6570\u578b numeric\uff08p,s\uff09\uff1a\u5b9a\u70b9\u6570\uff0c\u6574\u6570\u4f4d\u548c\u5c0f\u6570\u4f4d\u5171p\u4f4d\uff0c\u5c0f\u6570\u4f4ds\u4f4d\uff0c **10\uff0c2\u6574\u6570\u516b\u4f4d** 0&lt;=s&lt;=p&lt;=38 \u00b7 decimal\uff0c\u7528\u6cd5\u540cnumeric \u00b7**\u8d27\u5e01\u578b** \u00b7 money\u3001smallmoney \u65e5\u671f\u578b \u00b7datetime\uff1a\u7cbe\u786e\u5ea61\/300\u79d2\uff0c8\u5b57\u8282 ***\u8ba1\u7b97\u65b9\u6cd5:\u5f53\u524d\u65f6\u95f4-(1899-1-1-0:0\uff09*** \u00b7Smalldatetime\uff1a\u8303\u56f4\u7f29\u5c0f\uff0c\u7cbe\u786e\u5ea61\u79d2\uff0c4\u5b57\u8282 \u521b\u5efa\u8868 \u00b7\u8bbe\u8ba1\u8868\u7684\u7ed3\u6784\uff1a \u00b7\u5b57\u6bb5\u7684\u540d\u79f0 \u00b7\u6bcf\u4e2a\u5b57\u6bb5\u7684\u6570\u636e\u7c7b\u578b\u548c\u5bbd\u5ea6 \u00b7\u5b57\u6bb5\u662f\u5426\u5141\u8bb8\u4e3a\u7a7a \u00b7\u662f\u5426\u6709\u7f3a\u7701\u503c \u00b7\u662f\u5426\u4e3a\u6807\u8bc6\u5217 \u00b7\u662f\u5426\u4e3a\u4e3b\u952e\u3001\u5916\u952e \u8bed\u6cd51\uff1a CREATE TABLE \uff08[NULLI NOT &hellip; <a href=\"https:\/\/zd1269878.noblogs.org\/en-US\/post\/2025\/03\/21\/2025-03-21-%e6%95%b0%e6%8d%ae%e5%ba%93-%e7%ac%94%e8%ae%b0%e6%95%b4%e7%90%86\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">2025-03-21-\u6570\u636e\u5e93-\u7b14\u8bb0\u6574\u7406<\/span><\/a><\/p>\n","protected":false},"author":20615,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_locale":"en_US","_original_post":"https:\/\/zd1269878.noblogs.org\/?p=83","activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":""},"categories":[15],"tags":[16],"class_list":["post-83","post","type-post","status-publish","format-standard","hentry","category-15","tag-16","en-US"],"_links":{"self":[{"href":"https:\/\/zd1269878.noblogs.org\/wp-json\/wp\/v2\/posts\/83","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zd1269878.noblogs.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zd1269878.noblogs.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zd1269878.noblogs.org\/wp-json\/wp\/v2\/users\/20615"}],"replies":[{"embeddable":true,"href":"https:\/\/zd1269878.noblogs.org\/wp-json\/wp\/v2\/comments?post=83"}],"version-history":[{"count":13,"href":"https:\/\/zd1269878.noblogs.org\/wp-json\/wp\/v2\/posts\/83\/revisions"}],"predecessor-version":[{"id":287,"href":"https:\/\/zd1269878.noblogs.org\/wp-json\/wp\/v2\/posts\/83\/revisions\/287"}],"wp:attachment":[{"href":"https:\/\/zd1269878.noblogs.org\/wp-json\/wp\/v2\/media?parent=83"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zd1269878.noblogs.org\/wp-json\/wp\/v2\/categories?post=83"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zd1269878.noblogs.org\/wp-json\/wp\/v2\/tags?post=83"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}