
{"id":282,"date":"2021-07-31T15:56:15","date_gmt":"2021-07-31T07:56:15","guid":{"rendered":"http:\/\/dba.qishuo.xin\/?p=282"},"modified":"2021-08-01T17:10:04","modified_gmt":"2021-08-01T09:10:04","slug":"mariadb%e4%b8%a4%e4%b8%aa%e5%ba%93%e5%85%83%e6%95%b0%e6%8d%ae%e6%af%94%e8%be%83","status":"publish","type":"post","link":"http:\/\/dba.qishuo.xin\/?p=282","title":{"rendered":"MariaDB\u4e24\u4e2a\u5e93\u5143\u6570\u636e\u6bd4\u8f83"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_76 ez-toc-wrap-right counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<label for=\"ez-toc-cssicon-toggle-item-6a143bc4e45c7\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a143bc4e45c7\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"http:\/\/dba.qishuo.xin\/?p=282\/#1_%E8%A1%A8%E6%AF%94%E8%BE%83\" >1. \u8868\u6bd4\u8f83<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"http:\/\/dba.qishuo.xin\/?p=282\/#2_%E5%88%97%E6%AF%94%E8%BE%83\" >2. \u5217\u6bd4\u8f83<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"http:\/\/dba.qishuo.xin\/?p=282\/#3_%E7%B4%A2%E5%BC%95%E6%AF%94%E8%BE%83\" >3. \u7d22\u5f15\u6bd4\u8f83<\/a><\/li><\/ul><\/nav><\/div>\n<h3><span class=\"ez-toc-section\" id=\"1_%E8%A1%A8%E6%AF%94%E8%BE%83\"><\/span>1. \u8868\u6bd4\u8f83<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u6839\u636e\u5bf9\u8c61\u540d\u3001\u5bf9\u8c61\u7c7b\u578b\uff08\u8868\u6216\u89c6\u56fe\uff09\u3001\u6392\u5e8f\u89c4\u5219\u6765\u5224\u65ad\u662f\u5426\u4e00\u81f4\u3002<\/p>\n<pre><code class=\"language-sql line-numbers\">SELECT *\n  FROM information_schema.tables a\n WHERE a.table_schema = 'db_name1'\n   AND NOT EXISTS(SELECT 1\n                    FROM information_schema.tables b\n                   WHERE b.table_schema = 'db_name2'\n                     AND a.table_name = b.table_name\n                     AND a.table_type = b.table_type\n                     AND ifnull(a.table_collation,'###') = ifnull(b.table_collation,'###')\n                   );\n<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"2_%E5%88%97%E6%AF%94%E8%BE%83\"><\/span>2. \u5217\u6bd4\u8f83<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u6839\u636e\u8868\u540d\u3001\u5b57\u6bb5\u540d\u3001\u662f\u5426\u4e3a\u7a7a\u3001\u957f\u5ea6\u3001\u9ed8\u8ba4\u503c\u6765\u5224\u65ad\u662f\u5426\u4e00\u81f4\u3002<\/p>\n<pre><code class=\"language-sql line-numbers\">SELECT a.*\n  FROM information_schema.columns a\n WHERE a.table_schema = 'db_name1'\n   AND NOT EXISTS(SELECT 1\n                    FROM information_schema.columns b\n                   WHERE b.table_schema = 'db_name2'\n                     AND a.table_name = b.table_name\n                     AND a.column_name = b.column_name\n                     -- AND a.ordinal_position = b.ordinal_position\n                     AND a.is_nullable = b.is_nullable\n                     AND a.data_type = b.data_type\n                     AND a.column_type = b.column_type\n                     AND ifnull(a.column_default,'###') = ifnull(b.column_default,'###')\n                      );\n<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"3_%E7%B4%A2%E5%BC%95%E6%AF%94%E8%BE%83\"><\/span>3. \u7d22\u5f15\u6bd4\u8f83<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u5305\u542b\u4e3b\u952e\u7d22\u5f15\u4e0e\u666e\u901a\u7d22\u5f15\u3002\u6839\u636e\u8868\u540d\u3001\u7d22\u5f15\u540d\u79f0\u3001\u7d22\u5f15\u5b57\u6bb5\u5e8f\u53f7\u3001\u5217\u540d\u3001\u662f\u5426\u662f\u552f\u4e00\u7d22\u5f15\u6765\u5224\u65ad\u662f\u5426\u4e00\u81f4\u3002<\/p>\n<pre><code class=\"language-sql line-numbers\">SELECT a.*\n  FROM information_schema.statistics a\n WHERE a.table_schema = 'db_name1'\n   AND NOT EXISTS(SELECT 1\n                    FROM information_schema.statistics b\n                   WHERE b.table_schema = 'db_name2'\n                     AND a.table_name = b.table_name\n                     AND a.index_name = b.index_name\n                     AND a.seq_in_index = b.seq_in_index\n                     AND a.column_name = b.column_name\n                     AND a.non_unique = b.non_unique\n                   );\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1. \u8868\u6bd4\u8f83 \u6839\u636e\u5bf9\u8c61\u540d\u3001\u5bf9\u8c61\u7c7b\u578b\uff08\u8868\u6216\u89c6\u56fe\uff09\u3001\u6392&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29,3],"tags":[12,20,19],"class_list":["post-282","post","type-post","status-publish","format-standard","hentry","category-mariadb","category-mariadbmysql","tag-mariadb","tag-metadata","tag-19"],"_links":{"self":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts\/282","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=282"}],"version-history":[{"count":15,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts\/282\/revisions"}],"predecessor-version":[{"id":297,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts\/282\/revisions\/297"}],"wp:attachment":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=282"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=282"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=282"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}