{"id":5716,"date":"2024-11-14T08:28:47","date_gmt":"2024-11-14T00:28:47","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5716\/"},"modified":"2024-11-14T08:28:47","modified_gmt":"2024-11-14T00:28:47","slug":"sql%e5%bb%ba%e8%a1%a8%e6%80%8e%e4%b9%88%e7%bb%99%e5%ad%97%e6%ae%b5%e5%8a%a0%e6%a0%87%e6%b3%a8","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5716\/","title":{"rendered":"sql\u5efa\u8868\u600e\u4e48\u7ed9\u5b57\u6bb5\u52a0\u6807\u6ce8"},"content":{"rendered":"<blockquote><p>\n  \u4e3a sql \u8868\u5b57\u6bb5\u6dfb\u52a0\u6ce8\u91ca\u53ef\u4ee5\u63d0\u9ad8\u53ef\u8bfb\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u3002\u65b9\u6cd5\uff1a\u4f7f\u7528 comment \u5b50\u53e5\uff0c\u5c06\u5176\u4e0e create table \u6216 alter table \u8bed\u53e5\u4e00\u8d77\u4f7f\u7528\u3002\u8bed\u6cd5\uff1acreate table table_name (column_name data_type comment &#8216;comment&#8217;);\u6216alter table table_name add column column_name data_type comment &#8216;comment&#8217;;\u6ce8\u91ca\u7528\u5355\u5f15\u53f7\u62ec\u8d77\u6765\uff0c\u5e76\u5b58\u50a8\u5728\u6570\u636e\u5e93\u5143\u6570\u636e\u4e2d\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/30\/2024053021160479884.jpg\" class=\"aligncenter\" title=\"sql\u5efa\u8868\u600e\u4e48\u7ed9\u5b57\u6bb5\u52a0\u6807\u6ce8\u63d2\u56fe\" alt=\"sql\u5efa\u8868\u600e\u4e48\u7ed9\u5b57\u6bb5\u52a0\u6807\u6ce8\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u4e3a SQL \u8868\u4e2d\u7684\u5b57\u6bb5\u6dfb\u52a0\u6ce8\u91ca<\/strong><\/p>\n<p>\u5728 SQL \u4e2d\uff0c\u4e3a\u8868\u4e2d\u7684\u5b57\u6bb5\u6dfb\u52a0\u6ce8\u91ca\u662f\u8bb0\u5f55\u5b57\u6bb5\u542b\u4e49\u3001\u7ea6\u675f\u6216\u5176\u4ed6\u76f8\u5173\u4fe1\u606f\u7684\u6709\u6548\u65b9\u6cd5\u3002\u6ce8\u91ca\u6709\u52a9\u4e8e\u63d0\u9ad8\u6570\u636e\u5e93\u53ef\u8bfb\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u3002<\/p>\n<p><strong>\u65b9\u6cd5\uff1a<\/strong><\/p>\n<p>\u8981\u4e3a SQL \u8868\u4e2d\u7684\u5b57\u6bb5\u6dfb\u52a0\u6ce8\u91ca\uff0c\u9700\u8981\u4f7f\u7528 COMMENT \u5b50\u53e5\u3002\u8be5\u5b50\u53e5\u53ef\u4ee5\u4e0e CREATE TABLE \u6216 ALTER TABLE \u8bed\u53e5\u4e00\u8d77\u4f7f\u7528\u3002<\/p>\n<p><strong>\u8bed\u6cd5\uff1a<\/strong><\/p>\n<pre>CREATE TABLE table_name (\n  column_name data_type COMMENT 'comment'\n);<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u6216<\/strong><\/p>\n<pre>ALTER TABLE table_name\nADD COLUMN column_name data_type COMMENT 'comment';<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<p>\u4ee5\u4e0b\u793a\u4f8b\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3a customers \u7684\u8868\uff0c\u5176\u4e2d name \u5b57\u6bb5\u6709\u6ce8\u91ca &#8220;Customer&#8217;s full name&#8221;:<\/p>\n<pre>CREATE TABLE customers (\n  id INT NOT NULL PRIMARY KEY,\n  name VARCHAR(255) COMMENT 'Customer's full name'\n);<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u6ce8\u610f\u4e8b\u9879\uff1a<\/strong><\/p>\n<ul>\n<li>\u6ce8\u91ca\u5fc5\u987b\u7528\u5355\u5f15\u53f7 (&#8216;) \u62ec\u8d77\u6765\u3002<\/li>\n<li>\u6ce8\u91ca\u7684\u6700\u5927\u957f\u5ea6\u56e0\u6570\u636e\u5e93\u7c7b\u578b\u800c\u5f02\u3002<\/li>\n<li>\u6ce8\u91ca\u4e0d\u4f1a\u5b58\u50a8\u5728\u8868\u7684\u6570\u636e\u4e2d\uff0c\u800c\u662f\u5b58\u50a8\u5728\u6570\u636e\u5e93\u7684\u5143\u6570\u636e\u4e2d\u3002<\/li>\n<li>\u67d0\u4e9b\u6570\u636e\u5e93\u7cfb\u7edf\u53ef\u80fd\u652f\u6301\u4f7f\u7528\u5176\u4ed6\u5173\u952e\u5b57\uff08\u4f8b\u5982 DESCRIPTION\uff09\u6765\u6dfb\u52a0\u6ce8\u91ca\u3002\u8bf7\u53c2\u8003\u60a8\u7684\u6570\u636e\u5e93\u6587\u6863\u4ee5\u83b7\u53d6\u8be6\u7ec6\u4fe1\u606f\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fsql\u5efa\u8868\u600e\u4e48\u7ed9\u5b57\u6bb5\u52a0\u6807\u6ce8\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>\u4e3a sql \u8868\u5b57\u6bb5\u6dfb\u52a0\u6ce8\u91ca\u53ef\u4ee5\u63d0\u9ad8\u53ef\u8bfb\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u3002\u65b9\u6cd5\uff1a\u4f7f\u7528 comment \u5b50\u53e5\uff0c\u5c06\u5176\u4e0e create table \u6216 alter table \u8bed\u53e5\u4e00\u8d77\u4f7f\u7528\u3002\u8bed\u6cd5\uff1acreate table table_name (column_name data_type comment &#8216;comment&#8217;);\u6216alter table table_name add column column_name data_type comment &#8216;comment&#8217;;\u6ce8\u91ca\u7528\u5355\u5f15\u53f7\u62ec\u8d77\u6765\uff0c\u5e76\u5b58\u50a8\u5728\u6570\u636e\u5e93\u5143\u6570\u636e\u4e2d\u3002 \u5982\u4f55\u4e3a SQL \u8868\u4e2d\u7684\u5b57\u6bb5\u6dfb\u52a0\u6ce8\u91ca \u5728 SQL \u4e2d\uff0c\u4e3a\u8868\u4e2d\u7684\u5b57\u6bb5\u6dfb\u52a0\u6ce8\u91ca\u662f\u8bb0\u5f55\u5b57\u6bb5\u542b\u4e49\u3001\u7ea6\u675f\u6216\u5176\u4ed6\u76f8\u5173\u4fe1\u606f\u7684\u6709\u6548\u65b9\u6cd5\u3002\u6ce8\u91ca\u6709\u52a9\u4e8e\u63d0\u9ad8\u6570\u636e\u5e93\u53ef\u8bfb\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u3002 \u65b9\u6cd5\uff1a \u8981\u4e3a SQL \u8868\u4e2d\u7684\u5b57\u6bb5\u6dfb\u52a0\u6ce8\u91ca\uff0c\u9700\u8981\u4f7f\u7528 COMMENT \u5b50\u53e5\u3002\u8be5\u5b50\u53e5\u53ef\u4ee5\u4e0e CREATE TABLE \u6216 ALTER TABLE \u8bed\u53e5\u4e00\u8d77\u4f7f\u7528\u3002 \u8bed\u6cd5\uff1a CREATE TABLE table_name ( column_name data_type COMMENT &#8216;comment&#8217; ); \u767b\u5f55\u540e\u590d\u5236 \u6216 [&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-5716","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5716","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=5716"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5716\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5716"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5716"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5716"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}