{"id":76548,"date":"2024-10-16T07:43:37","date_gmt":"2024-10-15T23:43:37","guid":{"rendered":"https:\/\/server.hk\/cnblog\/76548\/"},"modified":"2024-10-16T07:43:37","modified_gmt":"2024-10-15T23:43:37","slug":"mysql%e6%95%b8%e6%93%9a%e5%ba%ab%e9%a1%9e%e5%9e%8b%e4%b8%80%e8%a6%bd-mysql%e7%9a%84%e6%95%b8%e6%93%9a%e5%ba%ab%e9%a1%9e%e5%9e%8b","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/76548\/","title":{"rendered":"MySQL\u6578\u64da\u5eab\u985e\u578b\u4e00\u89bd (MySQL\u7684\u6578\u64da\u5eab\u985e\u578b)"},"content":{"rendered":"<h1 id=\"mysql%e6%95%b8%e6%93%9a%e5%ba%ab%e9%a1%9e%e5%9e%8b%e4%b8%80%e8%a6%bd-mysql%e7%9a%84%e6%95%b8%e6%93%9a%e5%ba%ab%e9%a1%9e%e5%9e%8b-QniqSxKFNC\">MySQL\u6578\u64da\u5eab\u985e\u578b\u4e00\u89bd (MySQL\u7684\u6578\u64da\u5eab\u985e\u578b)<\/h1>\n<p>MySQL\u662f\u4e00\u7a2e\u6d41\u884c\u7684\u958b\u6e90\u95dc\u806f\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u5404\u7a2e\u61c9\u7528\u7a0b\u5e8f\u4e2d\u3002\u5b83\u652f\u6301\u591a\u7a2e\u6578\u64da\u5eab\u985e\u578b\uff0c\u9019\u4e9b\u985e\u578b\u6839\u64da\u4e0d\u540c\u7684\u9700\u6c42\u548c\u4f7f\u7528\u5834\u666f\u800c\u8a2d\u8a08\u3002\u672c\u6587\u5c07\u5c0dMySQL\u7684\u6578\u64da\u5eab\u985e\u578b\u9032\u884c\u8a73\u7d30\u4ecb\u7d39\uff0c\u5e6b\u52a9\u8b80\u8005\u66f4\u597d\u5730\u7406\u89e3\u5176\u7279\u6027\u548c\u9069\u7528\u60c5\u6cc1\u3002<\/p>\n<h2 id=\"1-innodb-QniqSxKFNC\">1. InnoDB<\/h2>\n<p>InnoDB\u662fMySQL\u7684\u9ed8\u8a8d\u5b58\u5132\u5f15\u64ce\uff0c\u63d0\u4f9b\u4e86\u4e8b\u52d9\u652f\u6301\u548c\u884c\u7d1a\u9396\u5b9a\u3002\u5b83\u7684\u4e3b\u8981\u7279\u9ede\u5305\u62ec\uff1a<\/p>\n<ul>\n<li><strong>\u4e8b\u52d9\u652f\u6301\uff1a<\/strong>InnoDB\u652f\u6301ACID\uff08\u539f\u5b50\u6027\u3001\u4e00\u81f4\u6027\u3001\u9694\u96e2\u6027\u3001\u6301\u4e45\u6027\uff09\u4e8b\u52d9\uff0c\u78ba\u4fdd\u6578\u64da\u7684\u5b8c\u6574\u6027\u3002<\/li>\n<li><strong>\u884c\u7d1a\u9396\u5b9a\uff1a<\/strong>\u76f8\u8f03\u65bc\u8868\u7d1a\u9396\u5b9a\uff0c\u884c\u7d1a\u9396\u5b9a\u80fd\u63d0\u9ad8\u4e26\u767c\u6027\u80fd\uff0c\u7279\u5225\u662f\u5728\u9ad8\u8ca0\u8f09\u7684\u74b0\u5883\u4e2d\u3002<\/li>\n<li><strong>\u5916\u9375\u652f\u6301\uff1a<\/strong>InnoDB\u652f\u6301\u5916\u9375\u7d04\u675f\uff0c\u9019\u5c0d\u65bc\u7dad\u8b77\u6578\u64da\u7684\u5b8c\u6574\u6027\u975e\u5e38\u91cd\u8981\u3002<\/li>\n<\/ul>\n<p>\u793a\u4f8b\uff1a\u5275\u5efa\u4e00\u500b\u4f7f\u7528InnoDB\u7684\u8868\u3002<\/p>\n<pre><code>CREATE TABLE users (\n    id INT AUTO_INCREMENT PRIMARY KEY,\n    username VARCHAR(50) NOT NULL,\n    password VARCHAR(50) NOT NULL\n) ENGINE=InnoDB;<\/code><\/pre>\n<h2 id=\"2-myisam-QniqSxKFNC\">2. MyISAM<\/h2>\n<p>MyISAM\u662fMySQL\u65e9\u671f\u7684\u5b58\u5132\u5f15\u64ce\uff0c\u96d6\u7136\u4e0d\u518d\u662f\u9ed8\u8a8d\u9078\u64c7\uff0c\u4f46\u4ecd\u7136\u88ab\u5ee3\u6cdb\u4f7f\u7528\u3002\u5176\u7279\u9ede\u5305\u62ec\uff1a<\/p>\n<ul>\n<li><strong>\u8868\u7d1a\u9396\u5b9a\uff1a<\/strong>MyISAM\u4f7f\u7528\u8868\u7d1a\u9396\u5b9a\uff0c\u9019\u5728\u67d0\u4e9b\u60c5\u6cc1\u4e0b\u53ef\u80fd\u5c0e\u81f4\u6027\u80fd\u74f6\u9838\u3002<\/li>\n<li><strong>\u5168\u6587\u7d22\u5f15\uff1a<\/strong>MyISAM\u652f\u6301\u5168\u6587\u7d22\u5f15\uff0c\u9069\u5408\u7528\u65bc\u641c\u7d22\u5927\u91cf\u6587\u672c\u6578\u64da\u3002<\/li>\n<li><strong>\u5feb\u901f\u8b80\u53d6\uff1a<\/strong>\u5728\u8b80\u53d6\u64cd\u4f5c\u983b\u7e41\u7684\u61c9\u7528\u4e2d\uff0cMyISAM\u7684\u6027\u80fd\u8868\u73fe\u512a\u7570\u3002<\/li>\n<\/ul>\n<p>\u793a\u4f8b\uff1a\u5275\u5efa\u4e00\u500b\u4f7f\u7528MyISAM\u7684\u8868\u3002<\/p>\n<pre><code>CREATE TABLE articles (\n    id INT AUTO_INCREMENT PRIMARY KEY,\n    title VARCHAR(100) NOT NULL,\n    content TEXT NOT NULL\n) ENGINE=MyISAM;<\/code><\/pre>\n<h2 id=\"3-memory-QniqSxKFNC\">3. MEMORY<\/h2>\n<p>MEMORY\u5b58\u5132\u5f15\u64ce\u5c07\u6578\u64da\u5b58\u5132\u5728\u5167\u5b58\u4e2d\uff0c\u63d0\u4f9b\u6975\u5feb\u7684\u6578\u64da\u8a2a\u554f\u901f\u5ea6\u3002\u5176\u7279\u9ede\u5305\u62ec\uff1a<\/p>\n<ul>\n<li><strong>\u5feb\u901f\u8a2a\u554f\uff1a<\/strong>\u7531\u65bc\u6578\u64da\u5b58\u5132\u5728\u5167\u5b58\u4e2d\uff0c\u8b80\u53d6\u548c\u5beb\u5165\u901f\u5ea6\u975e\u5e38\u5feb\u3002<\/li>\n<li><strong>\u6578\u64da\u6301\u4e45\u6027\uff1a<\/strong>\u7576MySQL\u670d\u52d9\u5668\u91cd\u555f\u6642\uff0cMEMORY\u8868\u4e2d\u7684\u6578\u64da\u6703\u4e1f\u5931\uff0c\u56e0\u6b64\u4e0d\u9069\u5408\u5b58\u5132\u91cd\u8981\u6578\u64da\u3002<\/li>\n<\/ul>\n<p>\u793a\u4f8b\uff1a\u5275\u5efa\u4e00\u500b\u4f7f\u7528MEMORY\u7684\u8868\u3002<\/p>\n<pre><code>CREATE TABLE temp_data (\n    id INT AUTO_INCREMENT PRIMARY KEY,\n    value VARCHAR(50) NOT NULL\n) ENGINE=MEMORY;<\/code><\/pre>\n<h2 id=\"4-csv-QniqSxKFNC\">4. CSV<\/h2>\n<p>CSV\u5b58\u5132\u5f15\u64ce\u5141\u8a31\u5c07\u6578\u64da\u4ee5\u9017\u865f\u5206\u9694\u503c\uff08CSV\uff09\u683c\u5f0f\u5b58\u5132\uff0c\u9069\u5408\u65bc\u6578\u64da\u5c0e\u5165\u548c\u5c0e\u51fa\u3002\u5176\u7279\u9ede\u5305\u62ec\uff1a<\/p>\n<ul>\n<li><strong>\u6613\u65bc\u5c0e\u5165\u5c0e\u51fa\uff1a<\/strong>CSV\u683c\u5f0f\u6613\u65bc\u8207\u5176\u4ed6\u61c9\u7528\u7a0b\u5e8f\u9032\u884c\u6578\u64da\u4ea4\u63db\u3002<\/li>\n<li><strong>\u4e0d\u652f\u6301\u7d22\u5f15\uff1a<\/strong>CSV\u8868\u4e0d\u652f\u6301\u7d22\u5f15\uff0c\u9019\u53ef\u80fd\u5f71\u97ff\u67e5\u8a62\u6027\u80fd\u3002<\/li>\n<\/ul>\n<p>\u793a\u4f8b\uff1a\u5275\u5efa\u4e00\u500b\u4f7f\u7528CSV\u7684\u8868\u3002<\/p>\n<pre><code>CREATE TABLE csv_data (\n    id INT,\n    name VARCHAR(50)\n) ENGINE=CSV;<\/code><\/pre>\n<h2 id=\"5-archive-QniqSxKFNC\">5. ARCHIVE<\/h2>\n<p>ARCHIVE\u5b58\u5132\u5f15\u64ce\u5c08\u70ba\u5b58\u5132\u5927\u91cf\u6578\u64da\u800c\u8a2d\u8a08\uff0c\u9069\u5408\u7528\u65bc\u65e5\u8a8c\u548c\u6b77\u53f2\u6578\u64da\u3002\u5176\u7279\u9ede\u5305\u62ec\uff1a<\/p>\n<ul>\n<li><strong>\u58d3\u7e2e\u5b58\u5132\uff1a<\/strong>ARCHIVE\u8868\u6703\u81ea\u52d5\u58d3\u7e2e\u6578\u64da\uff0c\u7bc0\u7701\u5b58\u5132\u7a7a\u9593\u3002<\/li>\n<li><strong>\u53ea\u652f\u6301\u63d2\u5165\u548c\u67e5\u8a62\uff1a<\/strong>\u4e0d\u652f\u6301\u66f4\u65b0\u548c\u522a\u9664\u64cd\u4f5c\uff0c\u9069\u5408\u65bc\u53ea\u9700\u5beb\u5165\u4e00\u6b21\u7684\u6578\u64da\u3002<\/li>\n<\/ul>\n<p>\u793a\u4f8b\uff1a\u5275\u5efa\u4e00\u500b\u4f7f\u7528ARCHIVE\u7684\u8868\u3002<\/p>\n<pre><code>CREATE TABLE logs (\n    id INT AUTO_INCREMENT PRIMARY KEY,\n    log_message TEXT NOT NULL\n) ENGINE=ARCHIVE;<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-QniqSxKFNC\">\u7e3d\u7d50<\/h2>\n<p>MySQL\u63d0\u4f9b\u4e86\u591a\u7a2e\u6578\u64da\u5eab\u985e\u578b\uff0c\u6bcf\u7a2e\u90fd\u6709\u5176\u7279\u5b9a\u7684\u512a\u52e2\u548c\u9069\u7528\u5834\u666f\u3002\u9078\u64c7\u5408\u9069\u7684\u6578\u64da\u5eab\u985e\u578b\u53ef\u4ee5\u986f\u8457\u63d0\u9ad8\u61c9\u7528\u7a0b\u5e8f\u7684\u6027\u80fd\u548c\u6578\u64da\u7ba1\u7406\u6548\u7387\u3002\u7121\u8ad6\u662f\u4f7f\u7528<strong><a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a><\/strong>\u9032\u884c\u958b\u767c\uff0c\u9084\u662f\u9078\u64c7\u5176\u4ed6\u670d\u52d9\uff0c\u4e86\u89e3\u9019\u4e9b\u6578\u64da\u5eab\u985e\u578b\u5c07\u6709\u52a9\u65bc\u60a8\u505a\u51fa\u66f4\u660e\u667a\u7684\u6c7a\u7b56\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22MySQL\u6578\u64da\u5eab\u7684\u5404\u7a2e\u985e\u578b\uff0c\u5305\u62ecInnoDB\u3001MyISAM\u7b49\uff0c\u4e86\u89e3\u5176\u7279\u9ede\u8207\u9069\u7528\u5834\u666f\uff0c\u52a9\u60a8\u9078\u64c7\u6700\u4f73\u89e3\u6c7a\u65b9\u6848\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-76548","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/76548","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"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=76548"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/76548\/revisions"}],"predecessor-version":[{"id":76549,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/76548\/revisions\/76549"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=76548"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=76548"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=76548"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}