{"id":1845,"date":"2023-09-22T20:10:47","date_gmt":"2023-09-22T12:10:47","guid":{"rendered":"https:\/\/white-night.club\/?p=1845"},"modified":"2023-11-09T11:07:52","modified_gmt":"2023-11-09T03:07:52","slug":"db4","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/09\/22\/db4\/","title":{"rendered":"\u6570\u636e\u5e93\u4e2d\u7684DDL\u4e0eDML"},"content":{"rendered":"\n<p>\u8bb0\u5f55\u4e0bDDL\u548cDML\u7684\u76f8\u5173\u6982\u5ff5\u3002<\/p>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u6570\u636e\u5b9a\u4e49\u8bed\u8a00<\/p>\n<cite><em>\u5b9a\u4e49\u6570\u636e\u5e93\u6a21\u5f0f<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u6570\u636e\u5b9a\u4e49\u8bed\u8a00DDL(Data-Definition Language)\u53ef\u5b9a\u4e49\u6570\u636e\u5e93\u6a21\u5f0f\u3002\u6570\u636e\u5e93\u6a21\u5f0f\u5728\u4e4b\u524d\u7684\u6587\u7ae0\u4e2d\u5df2\u7ecf\u63d0\u5230\u8fc7\u4e86\u3002\u7b80\u5355\u6765\u8bf4\uff0c\u5efa\u8868\u7528\u7684SQL\u8bed\u53e5\u5c31\u662fDDL\u3002\u5982\u4e0b\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CREATE TABLE department(dept_name char(20),building char(15),budget numeric(12,2));<\/code><\/pre>\n\n\n\n<p>\u8fd9\u4e2aSQL\u8bed\u53e5\u4fbf\u5b9a\u4e49\u4e86\u4e00\u5f20\u201cdepartment\u201d\u8868\u3002\u5e76\u5b9a\u4e49\u4e86\u8be5\u8868\u6709\u4e09\u4e2a\u5217\uff0c\u4ee5\u53ca\u4e0e\u8be5\u5217\u76f8\u5173\u7684\u6570\u636e\u7c7b\u578b\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full has-custom-border\"><img loading=\"lazy\" decoding=\"async\" width=\"351\" height=\"164\" src=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/09\/638e02f1a9fb2a247b8681c2b0b040f.png\" alt=\"\" class=\"wp-image-1850\" style=\"border-style:none;border-width:0px;border-radius:0px\" srcset=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/09\/638e02f1a9fb2a247b8681c2b0b040f.png 351w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/09\/638e02f1a9fb2a247b8681c2b0b040f-300x140.png 300w\" sizes=\"(max-width: 351px) 100vw, 351px\" \/><\/figure>\n\n\n\n<p>\u4e3a\u4ec0\u4e48\u8981\u6709DDL\u5462\uff1f\u4e4b\u524d\u63d0\u5230\u6570\u636e\u5e93\u6a21\u5f0f\u7684\u65f6\u5019\u6709\u8bf4\u8fc7\uff1a<mark style=\"background-color:rgba(0, 0, 0, 0);color:#fcb900\" class=\"has-inline-color\">\u6a21\u5f0f\u662f\u9884\u5148\u8bbe\u8ba1\u597d\u7684<\/mark>\u3002\u6bd4\u5982\u4e0a\u9762\u8fd9\u4e2adepartment\u8868\uff1a\u6309\u7167\u751f\u6d3b\u5e38\u8bc6\u6765\u8bb2\uff0c\u90e8\u95e8\u540d\u5b57\u4e0d\u4f1a\u662f\u5355\u4e2a\u6570\u5b57\uff0c\u800c\u9884\u7b97\u91d1\u989d\u4e00\u822c\u662f\u7eaf\u6570\u5b57\u3002\u6240\u4ee5\u6211\u4eec\u9650\u5236\u201cdept_name&#8221;\u5217\u7684\u6570\u636e\u7c7b\u578b\u4e3achar\uff0c\u201dbudget\u201c\u5217\u7684\u6570\u636e\u7c7b\u578b\u4e3anumeric\uff08\u6570\u5b57\u7684\uff09\u3002<\/p>\n\n\n\n<p>\u7ed3\u5408\u751f\u6d3b\u7ecf\u9a8c\u4e5f\u80fd\u77e5\u9053\uff0c\u5b58\u50a8\u5728\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\u503c\u90fd\u5fc5\u987b\u8981\u6ee1\u8db3\u67d0\u4e9b<mark style=\"background-color:rgba(0, 0, 0, 0);color:#fcb900\" class=\"has-inline-color\">\u4e00\u81f4\u6027\u7ea6\u675f<\/mark>\u3002\u9664\u4e86\u7a0b\u5e8f\u5458\u89c4\u5b9a\u7684\u4e00\u81f4\u6027\u7ea6\u675f\u4e4b\u5916\uff0c\u6570\u636e\u5e93\u7cfb\u7edf\u672c\u8eab\u5b9e\u73b0\u7684\u5219\u4e3a\uff08\u6570\u636e\uff09\u5b8c\u6574\u6027\u7ea6\u675f\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote has-vivid-cyan-blue-color has-text-color\">\n<p>\u5199\u8005\u6ce8<\/p>\n<cite>\u4e00\u81f4\u6027\u7ea6\u675f\uff1a\u6bd4\u5982\u6211\u4eec\u89c4\u5b9a\u4e00\u4e2a\u4eba\u7684\u59d3\u540d\u4e0d\u5141\u8bb8\u4e3a\u201c123\u201d\u3002\u5982\u679c\u51fa\u73b0\u4e86\u8be5\u60c5\u51b5\uff0c\u8868\u660e\u6709\u9519\u8bef\u7684\u6570\u636e\uff08\u6b64\u5904\u4e3a\u9519\u8bef\u7684\u6570\u636e\u7c7b\u578b\uff09\u8fdb\u5165\u5230\u4e86\u59d3\u540d\u6570\u636e\u5e93\u4e2d\uff0c\u5bfc\u81f4\u8be5\u6570\u636e\u548c\u8be5\u6570\u636e\u5e93\u7684\u7ea6\u675f\u201d\u4e0d\u4e00\u81f4\u201c\u3002<\/cite><\/blockquote>\n\n\n\n<ul>\n<li>\u57df\u7ea6\u675f(domain constraint)\uff1a\u6bcf\u4e2a\u6570\u636e\u5fc5\u987b\u5bf9\u5e94\u4e00\u4e2a\u6240\u6709\u53ef\u80fd\u53d6\u503c\u6784\u6210\u7684\u57df\u3002<mark style=\"background-color:rgba(0, 0, 0, 0);color:#fcb900\" class=\"has-inline-color\">\u57df\u7ea6\u675f\u4e5f\u662f\u5b8c\u6574\u6027\u7ea6\u675f\u7684\u6700\u57fa\u672c\u5f62\u5f0f<\/mark>\u3002<\/li>\n\n\n\n<li>\u5f15\u7528\u5b8c\u6574\u6027(referential integrity)\uff1a\u4e3e\u4e2a\u4f8b\u5b50\u3002\u4f60\u8003\u5b8c\u9a7e\u7167\u540e\uff0c\u5728\u9a7e\u7167\u7684\u6570\u636e\u5e93\uff08\u5047\u8bbe\u6709\u7684\u8bdd\uff09\u4e2d\u4f1a\u5f55\u5165\u4f60\u7684\u540d\u5b57Yname\u3002\u6b64\u524d\u5728\u516c\u5b89\u5c40\u90a3\u8fb9\u7684\u4eba\u53e3\u6570\u636e\u5e93\u4e2d\u4e5f\u5e94\u8be5\u6709\u4f60\u5bf9\u5e94\u7684YName\u3002\u7b80\u5355\u6765\u8bf4\uff1a\u4f60\u9a7e\u7167\u4e0a\u7684\u540d\u5b57\u5fc5\u987b\u662f\u4eba\u53e3\u6570\u636e\u5e93\u4e2d\u771f\u5b9e\u5b58\u5728\u7684\uff0c\u4f60\u9a7e\u7167\u4e0a\u7684\u540d\u5b57\u5b9e\u9645\u4e0a\u662f\u5f15\u7528\u4e86\u4eba\u53e3\u6570\u636e\u5e93\u4e2d\u7684\u201cName\u201d\u5217\u4e2d\u7684\u503c\u3002<\/li>\n\n\n\n<li>\u6388\u6743(authorization)\uff1a<mark style=\"background-color:rgba(0, 0, 0, 0);color:#fcb900\" class=\"has-inline-color\">\u4e0d\u540c\u7528\u6237\u5bf9\u4e8e\u6570\u636e\u5e93\u7684\u4e0d\u540c\u6570\u636e\u6709\u4e0d\u540c\u7684\u8bbf\u95ee\u6743\u9650<\/mark>\u3002\u8fd9\u4e2a\u4e5f\u5f88\u597d\u7406\u89e3\u3002\u6bd4\u5982\u4f60\u53ea\u80fd\u8bfb\u53d6\u4f60\u94f6\u884c\u5361\u6709\u591a\u5c11\u94b1\uff0c\u4f46\u4e0d\u80fd\u76f4\u63a5\u4fee\u6539\u4f60\u7684\u94f6\u884c\u5361\u91d1\u989d\uff0c\u4e5f\u4e0d\u80fd\u5220\u9664\u522b\u4eba\u7684\u94f6\u884c\u5361\u8d26\u6237\u3002<\/li>\n<\/ul>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u6570\u636e\u64cd\u7eb5\u8bed\u8a00<\/p>\n<cite><em>\u8bbf\u95ee\u6216\u64cd\u63a7\u6570\u636e<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u5982\u679c\u8bf4DDL\u662f\u603b\u5de5\u7a0b\u5e08\uff0c\u90a3\u6570\u636e\u64cd\u63a7\u8bed\u8a00DML(Data-Manipulation Language)\u5c31\u662f\u4e0b\u9762\u642c\u7816\u7684\u3002<\/p>\n\n\n\n<p>DML\u6709\u4ee5\u4e0b\u51e0\u79cd\u8bbf\u95ee\u7c7b\u578b\uff1a<\/p>\n\n\n\n<ul>\n<li>\u5bf9\u5b58\u50a8\u5728\u6570\u636e\u5e93\u4e2d\u7684\u4fe1\u606f\u8fdb\u884c\u68c0\u7d22<\/li>\n\n\n\n<li>\u5411\u6570\u636e\u5e93\u63d2\u5165\u65b0\u7684\u4fe1\u606f<\/li>\n\n\n\n<li>\u5220\u9664\u6570\u636e\u5e93\u4e2d\u7684\u4fe1\u606f<\/li>\n\n\n\n<li>\u4fee\u6539\u6570\u636e\u5e93\u4e2d\u7684\u4fe1\u606f<\/li>\n<\/ul>\n\n\n\n<p>DML\u6709\u4ee5\u4e0b\u4e24\u79cd\u7c7b\u578b\uff1a<\/p>\n\n\n\n<ul>\n<li>\u8fc7\u7a0b\u5316\u7684DML(procedural DML)\uff1a\u8981\u6c42\u7528\u6237\u6307\u5b9a\u9700\u8981\u4ec0\u4e48\u6570\u636e\uff0c<mark style=\"background-color:rgba(0, 0, 0, 0);color:#fcb900\" class=\"has-inline-color\">\u4ee5\u53ca\u5982\u4f55\u83b7\u5f97\u8fd9\u4e9b\u6570\u636e<\/mark>\u3002<\/li>\n\n\n\n<li>\u58f0\u660e\u5316\u7684DML(declarative DML)\uff1a\u4e5f\u79f0\u4e3a\u975e\u8fc7\u7a0b\u5316\u7684DML\u3002<mark style=\"background-color:rgba(0, 0, 0, 0);color:#fcb900\" class=\"has-inline-color\">\u53ea\u8981\u6c42\u7528\u6237\u6307\u5b9a\u9700\u8981\u4ec0\u4e48\u6570\u636e<\/mark>\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u5f88\u660e\u663e\u540e\u8005\u6bd4\u8fc7\u7a0b\u5316\u7684DML\u7b80\u5355\uff0c\u6211\u4eec\u5728SQL\u4e2d\u6700\u5e38\u7528\u7684\u201c\u67e5\u8be2\u8bed\u53e5\u201c(query language)\u5c31\u662f\u975e\u8fc7\u7a0b\u5316\u7684DML\u3002\u6bd4\u5982\u4e0b\u9762\u8fd9\u6bb5\u6700\u76f4\u63a5\u7684\u67e5\u8be2\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT * FROM department;<\/code><\/pre>\n\n\n\n<p>\u5728mysql\u4e2d\u8bd5\u4e00\u4e0b\uff0c\u6548\u679c\u5982\u56fe<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full has-custom-border\"><img loading=\"lazy\" decoding=\"async\" width=\"384\" height=\"184\" src=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/09\/8d2168efaaf5b897eb8bd53157773d5.png\" alt=\"\" class=\"wp-image-1855\" style=\"border-style:none;border-width:0px;border-radius:0px\" srcset=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/09\/8d2168efaaf5b897eb8bd53157773d5.png 384w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/09\/8d2168efaaf5b897eb8bd53157773d5-300x144.png 300w\" sizes=\"(max-width: 384px) 100vw, 384px\" \/><\/figure>\n\n\n\n<p>\u800c\u8fc7\u7a0b\u5316\u7684DML\u5728Oracle\u90a3\u5757\u7684PL\/SQL\u201c\u8c8c\u4f3c\u201d\u7ecf\u5e38\u88ab\u63d0\u53ca\uff0c\u4ee5\u540e\u78b0\u5230\u518d\u8bb0\u5f55\u5427\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote has-vivid-cyan-blue-color has-text-color\">\n<p>\u5199\u8005\u6ce8<\/p>\n<cite>\u53bb\u535a\u5ba2\u56ed\u4e0a\u4e5f\u6ca1\u627e\u5230\u4e13\u95e8\u8bf4\u201c\u8fc7\u7a0b\u5316DML\u201d\u7684\u6587\u7ae0\u3002\u867d\u7136\u6211\u4e2a\u4eba\u8ba4\u4e3a\u50cfSELECT\u8fd9\u79cd\u5e94\u8be5\u7b97\u8fc7\u7a0b\u5316\u7684DML\uff0c\u56e0\u4e3a\u8981\u6307\u660e\u4ece\u54ea\u4e2a\u8868\u83b7\u53d6\u6570\u636e\u3002\u4f46\u5fc3\u91cc\u8fd8\u662f\u6ca1\u4e2a\u5e95\u3002<\/cite><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>\u6570\u636e\u5b9a\u4e49\u8bed\u8a00\uff0c\u6570\u636e\u64cd\u7eb5\u8bed\u8a00<\/p>\n","protected":false},"author":1,"featured_media":1850,"comment_status":"open","ping_status":"","sticky":false,"template":"base","format":"standard","meta":{"footnotes":""},"categories":[35,76],"tags":[80],"_links":{"self":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/1845"}],"collection":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/comments?post=1845"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/1845\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media\/1850"}],"wp:attachment":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media?parent=1845"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=1845"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=1845"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}