{"id":200093,"date":"2025-05-06T10:41:37","date_gmt":"2025-05-06T02:41:37","guid":{"rendered":"https:\/\/server.hk\/cnblog\/200093\/"},"modified":"2025-05-06T10:41:37","modified_gmt":"2025-05-06T02:41:37","slug":"mysql%e6%95%b0%e6%8d%ae%e5%ba%93%e5%af%b9%e5%a4%a7%e5%b0%8f%e5%86%99%e6%95%8f%e6%84%9f%e5%90%97%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/200093\/","title":{"rendered":"MySQL\u6570\u636e\u5e93\u5bf9\u5927\u5c0f\u5199\u654f\u611f\u5417\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>MySQL\u6570\u636e\u5e93\u5bf9\u5927\u5c0f\u5199\u654f\u611f\u5417\uff1f<\/h1>\n<p>MySQL\u6570\u636e\u5e93\u5bf9\u5927\u5c0f\u5199\u654f\u611f\uff0c\u8fd9\u53ef\u80fd\u4f1a\u5bfc\u81f4\u67e5\u8be2\u3001\u63d2\u5165\u548c\u66f4\u65b0\u64cd\u4f5c\u4e2d\u51fa\u73b0\u610f\u5916\u7ed3\u679c\u3002\u5728\u521b\u5efa\u6570\u636e\u5e93\u8868\u3001\u6267\u884c\u67e5\u8be2\u6216\u8fdb\u884c\u6570\u636e\u64cd\u4f5c\u65f6\uff0c\u5fc5\u987b\u51c6\u786e\u5339\u914d\u5927\u5c0f\u5199\uff0c\u5426\u5219\u6570\u636e\u5e93\u53ef\u80fd\u4f1a\u5c06\u5176\u89c6\u4e3a\u4e0d\u540c\u7684\u6570\u636e\u3002\u4f8b\u5982\uff0c\u67e5\u8be2&#8221;JohnDoe&#8221;\u548c&#8221;johndoe&#8221;\u5c06\u8fd4\u56de\u4e0d\u540c\u7684\u7ed3\u679c\uff0c\u63d2\u5165&#8221;johndoe&#8221;\u548c&#8221;JohnDoe&#8221;\u5c06\u521b\u5efa\u4e0d\u540c\u7684\u8bb0\u5f55\uff0c\u66f4\u65b0&#8221;janedoe&#8221;\u5c06\u6267\u884c\u66f4\u65b0\u64cd\u4f5c\uff0c\u5373\u4f7f&#8221;JaneDoe&#8221;\u5df2\u5b58\u5728\u3002\u56e0\u6b64\uff0c\u5728\u4f7f\u7528MySQL\u6570\u636e\u5e93\u65f6\uff0c\u5fc5\u987b\u6ce8\u610f\u5927\u5c0f\u5199\u7684\u4e00\u81f4\u6027\uff0c\u4ee5\u907f\u514d\u56e0\u5927\u5c0f\u5199\u654f\u611f\u6027\u5e26\u6765\u7684\u95ee\u9898\u3002<\/p>\n<p>MySQL\u6570\u636e\u5e93\u5bf9\u5927\u5c0f\u5199\u654f\u611f\u5417\uff1f\u9700\u8981\u5177\u4f53\u4ee3\u7801\u793a\u4f8b<\/p>\n<p>\u5728\u4f7f\u7528MySQL\u6570\u636e\u5e93\u65f6\uff0c\u6709\u65f6\u4f1a\u9047\u5230\u5927\u5c0f\u5199\u654f\u611f\u7684\u95ee\u9898\uff0c\u5373\u5728\u67e5\u8be2\u3001\u63d2\u5165\u6216\u66f4\u65b0\u6570\u636e\u65f6\uff0c\u4e0d\u540c\u5927\u5c0f\u5199\u7684\u60c5\u51b5\u53ef\u80fd\u4f1a\u5bfc\u81f4\u4e0d\u540c\u7684\u7ed3\u679c\u3002MySQL\u6570\u636e\u5e93\u5728\u5bf9\u5927\u5c0f\u5199\u7684\u5904\u7406\u4e0a\u662f\u6709\u4e00\u5b9a\u7684\u654f\u611f\u6027\u7684\uff0c\u4e0b\u9762\u6211\u4eec\u901a\u8fc7\u5177\u4f53\u7684\u4ee3\u7801\u793a\u4f8b\u6765\u6df1\u5165\u63a2\u8ba8MySQL\u6570\u636e\u5e93\u5bf9\u5927\u5c0f\u5199\u7684\u654f\u611f\u6027\u3002<\/p>\n<p>\u9996\u5148\uff0c\u6211\u4eec\u6765\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u6570\u636e\u5e93\u8868\u683c\uff0c\u7528\u6765\u8fdb\u884c\u793a\u4f8b\u6f14\u793a\uff1a<\/p>\n<pre>CREATE TABLE users (\n    id INT PRIMARY KEY,\n    username VARCHAR(50)\n);\n\nINSERT INTO users (id, username) VALUES (1, 'JohnDoe');\nINSERT INTO users (id, username) VALUES (2, 'janedoe');<\/pre>\n<p>\u4e0a\u8ff0\u4ee3\u7801\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3a<code>users<\/code>\u7684\u8868\u683c\uff0c\u5305\u542b\u4e86<code>id<\/code>\u548c<code>username<\/code>\u4e24\u4e2a\u5b57\u6bb5\uff0c\u5e76\u63d2\u5165\u4e86\u4e24\u6761\u8bb0\u5f55\u3002\u5176\u4e2d\uff0c<code>username<\/code>\u5b57\u6bb5\u5b58\u50a8\u4e86\u4e0d\u540c\u5927\u5c0f\u5199\u7684\u7528\u6237\u540d\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u901a\u8fc7\u4ee3\u7801\u793a\u4f8b\u6765\u89c2\u5bdfMySQL\u6570\u636e\u5e93\u5728\u4e0d\u540c\u60c5\u51b5\u4e0b\u5bf9\u5927\u5c0f\u5199\u7684\u5904\u7406\uff1a<\/p>\n<ol>\n<li>\u67e5\u8be2\u64cd\u4f5c\uff1a<\/li>\n<\/ol>\n<pre>SELECT * FROM users WHERE username = 'JohnDoe';<\/pre>\n<p>\u4e0a\u8ff0\u67e5\u8be2\u8bed\u53e5\u4e2d\uff0c<code>username<\/code>\u4f7f\u7528\u4e86\u5927\u5c0f\u5199\u6df7\u5408\u7684\u5f62\u5f0f\u3002MySQL\u6570\u636e\u5e93\u4f1a\u5bf9\u5927\u5c0f\u5199\u8fdb\u884c\u654f\u611f\u5339\u914d\uff0c\u53ea\u6709\u5f53\u5927\u5c0f\u5199\u5b8c\u5168\u4e00\u81f4\u65f6\u624d\u4f1a\u8fd4\u56de\u7ed3\u679c\u3002<\/p>\n<ol>\n<li>\u63d2\u5165\u64cd\u4f5c\uff1a<\/li>\n<\/ol>\n<pre>INSERT INTO users (id, username) VALUES (3, 'johndoe');<\/pre>\n<p>\u5728\u63d2\u5165\u64cd\u4f5c\u4e2d\uff0cMySQL\u6570\u636e\u5e93\u540c\u6837\u4f1a\u5bf9\u5927\u5c0f\u5199\u8fdb\u884c\u654f\u611f\u6027\u68c0\u67e5\u3002\u867d\u7136<code>johndoe<\/code>\u4e0e<code>JohnDoe<\/code>\u770b\u4f3c\u76f8\u4f3c\uff0c\u4f46\u7531\u4e8e\u5927\u5c0f\u5199\u4e0d\u540c\uff0c\u6570\u636e\u5e93\u4f1a\u5c06\u5176\u4f5c\u4e3a\u4e0d\u540c\u7684\u8bb0\u5f55\u63d2\u5165\u3002<\/p>\n<ol>\n<li>\u66f4\u65b0\u64cd\u4f5c\uff1a<\/li>\n<\/ol>\n<pre>UPDATE users SET username = 'JaneDoe' WHERE id = 2;<\/pre>\n<p>\u5728\u66f4\u65b0\u64cd\u4f5c\u4e2d\uff0c\u5bf9\u5927\u5c0f\u5199\u7684\u654f\u611f\u6027\u540c\u6837\u9002\u7528\u3002\u5373\u4f7f<code>janedoe<\/code>\u662f\u5df2\u5b58\u5728\u7684\u8bb0\u5f55\uff0c\u4f46\u7531\u4e8e\u5927\u5c0f\u5199\u4e0d\u5339\u914d\uff0c\u66f4\u65b0\u64cd\u4f5c\u4e5f\u4f1a\u88ab\u6267\u884c\uff0c\u800c\u4e0d\u662f\u88ab\u89c6\u4e3a\u91cd\u590d\u6570\u636e\u3002<\/p>\n<p>\u7efc\u4e0a\u6240\u8ff0\uff0cMySQL\u6570\u636e\u5e93\u5bf9\u5927\u5c0f\u5199\u662f\u654f\u611f\u7684\uff0c\u9700\u8981\u5728\u64cd\u4f5c\u4e2d\u51c6\u786e\u5339\u914d\u5927\u5c0f\u5199\u624d\u80fd\u83b7\u5f97\u6b63\u786e\u7684\u7ed3\u679c\u3002\u5728\u7f16\u5199\u4ee3\u7801\u65f6\uff0c\u52a1\u5fc5\u6ce8\u610f\u5927\u5c0f\u5199\u7684\u4e00\u81f4\u6027\uff0c\u4ee5\u907f\u514d\u56e0\u4e3a\u5927\u5c0f\u5199\u654f\u611f\u6027\u5e26\u6765\u7684\u95ee\u9898\u3002<\/p>\n<p>\u901a\u8fc7\u4ee5\u4e0a\u4ee3\u7801\u793a\u4f8b\uff0c\u5e0c\u671b\u8bfb\u8005\u80fd\u66f4\u52a0\u6df1\u5165\u4e86\u89e3MySQL\u6570\u636e\u5e93\u5728\u5904\u7406\u5927\u5c0f\u5199\u65f6\u7684\u884c\u4e3a\uff0c\u4ece\u800c\u66f4\u52a0\u51c6\u786e\u5730\u8fdb\u884c\u6570\u636e\u5e93\u64cd\u4f5c\u3002<\/p>\n<p>\u597d\u4e86\uff0c\u672c\u6587\u5230\u6b64\u7ed3\u675f\uff0c\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u300aMySQL\u6570\u636e\u5e93\u5bf9\u5927\u5c0f\u5199\u654f\u611f\u5417\uff1f\u300b\uff0c\u5e0c\u671b\u672c\u6587\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff01\u5173\u6ce8\u4e3b\u673a\u5b9d\u8d1d\u516c\u4f17\u53f7\uff0c\u7ed9\u5927\u5bb6\u5206\u4eab\u66f4\u591a\u6570\u636e\u5e93\u77e5\u8bc6\uff01<\/p>\n<dl>\n<dt>\n <\/dt>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>MySQL\u6570\u636e\u5e93\u5bf9\u5927\u5c0f\u5199\u654f\u611f\u5417\uff1f&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-200093","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/200093","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=200093"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/200093\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=200093"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=200093"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=200093"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}