{"id":284,"date":"2007-04-16T23:54:47","date_gmt":"2007-04-16T15:54:47","guid":{"rendered":"http:\/\/www.jason695.idv.tw:81\/wordpress\/?p=284"},"modified":"2007-04-17T20:13:12","modified_gmt":"2007-04-17T12:13:12","slug":"mysql%e9%9c%80%e6%b3%a8%e6%84%8f%e7%9a%84%e5%b9%be%e9%bb%9etips","status":"publish","type":"post","link":"https:\/\/jason695.why3s.tw\/wordpress\/2007\/04\/16\/mysql%e9%9c%80%e6%b3%a8%e6%84%8f%e7%9a%84%e5%b9%be%e9%bb%9etips\/","title":{"rendered":"MySQL\u9700\u6ce8\u610f\u7684\u5e7e\u9edetips"},"content":{"rendered":"<p>1\u3001\u7528mysql\u5167\u7f6e\u51fd\u6578\u8f49\u63dbip\u5730\u5740\u548c\u6578\u5b57<br \/>\n\u5229\u7528\u5169\u500b\u5167\u7f6e\u51fd\u6578<br \/>\ninet_aton:\u5c07ip\u5730\u5740\u8f49\u63db\u6210\u6578\u5b57\u578b<br \/>\ninet_ntoa:\u5c07\u6578\u5b57\u578b\u8f49\u63db\u6210ip\u5730\u5740<\/p>\n<p>2\u3001\u5145\u5206\u5229\u7528mysql\u5167\u7f6e\u7684format\u51fd\u6578<br \/>\n\u5c24\u5176\u662f\u5728\u8655\u7406\u5b57\u7b26\u683c\u5f0f\u7684\u6642\u5019,\u4f8b\u5982\u5c0712345\u8f49\u63db\u621012,345\u9019\u6a23\u7684,\u53ea\u8981\u7528:format(12345,0)\u5373\u53ef,\u5982\u679c\u7528format(12345,2)\u5247\u986f\u793a\u7684\u662f12,345.00\u4e86&#8230;<\/p>\n<p>3\u3001\u5229\u7528mysql\u7684\u5167\u7f6e\u51fd\u6578\u8655\u7406\u6642\u9593\u6233\u554f\u984c<br \/>\neg : select FROM_UNIXTIME(UNIX_TIMESTAMP(),&#8217;%Y %D %M %h:%i:%s %x&#8217;);<br \/>\n\u7d50\u679c: 2004 3rd August 03:35:48 2004<\/p>\n<p>4\u3001\u5229\u7528mysql_convert_table_format\u8f49\u63db\u8868\u985e\u578b<br \/>\n\u9700\u8981DBI\u548cDBD\u7684mysql\u76f8\u95dc\u6a21\u7d44\u652f\u63f4\u624d\u80fd\u7528,\u4f8b\u5b50:<br \/>\nmysql_convert_table_format &#8211;user=root &#8211;password=&#8217;xx&#8217; &#8211;type=myisam test yejr<\/p>\n<p>5\u3001\u4fee\u6539mysql\u8868\u4e2d\u7684\u5b57\u6bb5\u540d<br \/>\nalter table tb_name change old_col new_col definition&#8230;<\/p>\n<p>6\u3001\u5229\u7528\u81e8\u6642\u8b8a\u6578<br \/>\nselect @var1:=a1+a2 as a_sum,@var2:=b1+b2 as b_sum,@var1+@var2 as total_sum from test_table xxx;<\/p>\n<p>7\u3001\u7528int\u985e\u578b\u5b58\u5132ip\u5730\u5740<br \/>\n\u539f\u5148\u932f\u8aa4\u7684\u8a8d\u70ba\u5fc5\u9808\u7528bigint\u624d\u5920\uff0c\u5f8c\u4f86\u767c\u73fe\u4f7f\u7528int unsigned\u985e\u578b\u5c31\u8db3\u5920\u4e86\u3002 :)<\/p>\n<p>8\u3001CREATE TABLE IF NOT EXISTS &#8230; select \u8a9e\u6cd5\u5c40\u9650<br \/>\n\u5118\u7ba1\u53ea\u662f\u5c0d\u76ee\u6a19\u8868\u7684insert\u64cd\u4f5c\uff0c\u4f46\u662f\u2018\u5c45\u7136\u2019\u4e0d\u5141\u8a31\u6e90\u8868\u7684insert\u64cd\u4f5c\uff0c\u771f\u662f\u83ab\u540d\u5176\u5999<\/p>\n<p>9\u3001\u5229\u7528IF\u51fd\u6578\u5feb\u901f\u4fee\u6539ENUM\u5b57\u6bb5\u503c<br \/>\n\u4e00\u500b\u4f8b\u5b50\uff1a<br \/>\nupdate rule set enable = if(&#8216;0&#8242; = enable,&#8217;1&#8242;,&#8217;0&#8217;) where xxx;<br \/>\nenable \u985e\u578b\uff1aenum(&#8216;0&#8242;,&#8217;1&#8217;) not null default &#8216;0&#8217;<\/p>\n<p>10\u3001\u4e8b\u52d9\u7121\u6cd5\u5d4c\u5957<\/p>\n<p>11\u3001\u907f\u514d\u9577\u6642\u9593\u7684sleep\u9023\u63a5\u9020\u6210\u7684\u9023\u63a5\u6578\u8d85\u51fa\u554f\u984c<br \/>\n\u8a2d\u5b9a\u5168\u5c40\u8b8a\u6578 wait_timeout \u548c interactive_timeout \u70ba\u6bd4\u8f03\u5c0f\u7684\u503c\uff0c\u4f8b\u5982 10(s)\uff0c\u5c31\u80fd\u4f7f\u6bcf\u500bsleep\u9023\u63a5\u572810s\u4e4b\u5f8c\u5982\u679c\u9084\u6c92\u6709\u67e5\u8a62\u7684\u8a71\u81ea\u52d5\u65b7\u958b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u7528mysql\u5167\u7f6e\u51fd\u6578\u8f49\u63dbip\u5730\u5740\u548c\u6578\u5b57 \u5229\u7528\u5169\u500b\u5167\u7f6e\u51fd\u6578 inet_aton:\u5c07ip\u5730\u5740\u8f49\u63db\u6210\u6578\u5b57\u578b in &hellip; <a href=\"https:\/\/jason695.why3s.tw\/wordpress\/2007\/04\/16\/mysql%e9%9c%80%e6%b3%a8%e6%84%8f%e7%9a%84%e5%b9%be%e9%bb%9etips\/\" class=\"more-link\">\u95b1\u8b80\u5168\u6587 <span class=\"screen-reader-text\">MySQL\u9700\u6ce8\u610f\u7684\u5e7e\u9edetips<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[5],"tags":[],"class_list":["post-284","post","type-post","status-publish","format-standard","hentry","category-5","no-featured-image"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/posts\/284","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/comments?post=284"}],"version-history":[{"count":0,"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/posts\/284\/revisions"}],"wp:attachment":[{"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/media?parent=284"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/categories?post=284"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/tags?post=284"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}