{"id":2047,"date":"2020-07-29T23:25:12","date_gmt":"2020-07-29T15:25:12","guid":{"rendered":"http:\/\/39.97.231.10\/?p=2047"},"modified":"2020-07-29T23:25:12","modified_gmt":"2020-07-29T15:25:12","slug":"mysql%e6%95%b0%e6%8d%ae%e7%b1%bb%e5%9e%8b-%e6%95%b0%e5%80%bc%e5%9e%8b","status":"publish","type":"post","link":"http:\/\/www.weijing.co\/?p=2047","title":{"rendered":"MySQL\u6570\u636e\u7c7b\u578b-\u6570\u503c\u578b"},"content":{"rendered":"<div class=\\\"blog_content\\\">\n<div class=\\\"blog_detail\\\">\n<div>\n\u6570\u503c\u7c7b\u578b\u662fMySQL\u6700\u57fa\u672c\u7684\u6570\u636e\u7c7b\u578b\uff0c\u4e5f\u662f\u4f7f\u7528\u6700\u591a\u7684\u7c7b\u578b\uff0c\u4e3b\u8981\u5305\u62ec\u6574\u578b\u3001\u6d6e\u70b9\u578b\u3001\u7cbe\u786e\u6570\u503c\u578b\u7b49\u3002<\/p>\n<h5>\u6570\u503c\u7c7b\u578b\uff1a<\/h5>\n<ul>\n<li>BIT<\/li>\n<li>TINYINT<\/li>\n<li>BOOL\/BOOLEAN<\/li>\n<li>SMALLINT<\/li>\n<li>MEDIUMINT<\/li>\n<li>INT\/INTEGER<\/li>\n<li>BIGINT<\/li>\n<li>DECIMAL\/DEC\/FIXED<\/li>\n<li>FLOAT<\/li>\n<li>DOUBLE\/REAL<\/li>\n<\/ul>\n<h5>BIT\uff1a<\/h5>\n<p>\u4f4d\u7c7b\u578b\uff0c\u4f4d\u957f\u5ea6\u4e3a1~64\uff0c\u9ed8\u8ba4\u4e3a1\u3002<br \/>\n\u793a\u4f8b\uff1a<br \/>\ncreate table t(bitmap bit(10));<br \/>\ninsert into t value(b\\&#8217;1101001011\\&#8217;);<br \/>\nselect bin(bitmap) from t;<\/p>\n<h5>TINYINT\uff1a<\/h5>\n<p>1\u4e2a\u5b57\u8282\u7684\u6574\u578b\uff0c\u53d6\u503c\u8303\u56f4\u4e3a-128~127\uff0cTINYINT UNSIGNED \u53d6\u503c\u8303\u56f4\u4e3a0~255\u3002<br \/>\n\u793a\u4f8b\uff1a<br \/>\ncreate table t(id tinyint);<br \/>\ninsert into t values(1);<\/p>\n<h5>BOOL\/BOOLEAN\uff1a<\/h5>\n<p>BOOL\/BOOLEAN\u5b9e\u9645\u4e0a\u662f\u4e00\u4e2aTINYINT\uff0c0\u4e3aFALSE\uff0c\u975e0\u4e3aTRUE\u3002<br \/>\ncreate table t(id bool);<br \/>\ninsert into t values(true);<\/p>\n<h5>SMALLINT\uff1a<\/h5>\n<p>2\u4e2a\u5b57\u8282\u7684\u6574\u578b\uff0c\u53d6\u503c\u8303\u56f4\u4e3a-32768~32767\uff0cSMALLINT UNSIGNED\u53d6\u503c\u8303\u56f4\u4e3a0\u00a0~\u00a065535\u3002<br \/>\n\u793a\u4f8b\uff1a<br \/>\ncreate table t(id\u00a0 smallint unsigned);<\/p>\n<h5>MEDIUMINT\uff1a<\/h5>\n<p>3\u4e2a\u5b57\u8282\u7684\u6574\u578b\uff0c\u53d6\u503c\u8303\u56f4\u4e3a-8388608~8388607\uff0cMEDIUMINT UNSIGNED \u53d6\u503c\u8303\u56f4\u4e3a<br \/>\n0~16777215\u3002<br \/>\n\u793a\u4f8b\uff1a<br \/>\ncreate table t(id mediumint);<\/p>\n<h5>INT\/INTEGER\uff1a<\/h5>\n<p>4\u4e2a\u5b57\u8282\u7684\u6574\u578b\uff0c\u53d6\u503c\u8303\u56f4\u4e3a-2147483648~2147483647\uff0cINT UNSIGNED \u53d6\u503c\u8303\u56f4\u4e3a0~4294967295\u3002<br \/>\n\u793a\u4f8b\uff1a<br \/>\ncreate table t(id integer unsigned);<\/p>\n<h5>BIGINT\uff1a<\/h5>\n<p>8\u5b57\u8282\u7684\u6574\u578b\uff0c\u53d6\u503c\u8303\u56f4\u4e3a-9223372036854775808~9223372036854775807\uff0cBIGINT UNSIGNED\u53d6\u503c\u8303\u56f4\u4e3a0~18446744073709551615\u3002<br \/>\nSERIAL \u7c7b\u578b\u5b9e\u9645\u4e0a\u662fBIGINT\u7684\u4e00\u4e2a\u522b\u540d\uff0c\u76f8\u5f53\u4e8e BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE<br \/>\n\u793a\u4f8b\uff1a<br \/>\ncreate table t(id bigint unsigned);<\/p>\n<h5>DECIMAL(M,D)\uff1a<\/h5>\n<p>\u7cbe\u786e\u6570\u503c\u7c7b\u578b\uff0c\u80fd\u591f\u5b9a\u4e49\u5c0f\u6570\u70b9\u524d\u540e\u7684\u4f4d\u6570\uff0cM\u8868\u793a\u5c0f\u6570\u70b9\u524d\u540e\u603b\u7684\u4f4d\u6570\uff0c\u6700\u5927\u4e3a65\uff0cD\u4e3a\u5c0f\u6570\u70b9\u540e\u7684\u4f4d\u6570\uff0c\u6700\u5927\u4e3a30\u3002\u5e38\u7528\u4e8e\u91d1\u878d\u8d27\u5e01\uff0c\u9700\u8981\u7cbe\u786e\u8ba1\u7b97\u7684\u573a\u5408\u3002DEC\/FIXED\u90fd\u662fDECIMAL\u7684\u522b\u540d\u3002<br \/>\n\u793a\u4f8b\uff1a<br \/>\ncreate table t(id decimal(65,30));<\/p>\n<h5>FLOAT(M,D)\uff1a<\/h5>\n<p>\u5355\u7cbe\u5ea6\u6d6e\u70b9\u6570\u7c7b\u578b\uff0c\u5360\u75284\u4e2a\u5b57\u8282\u3002<br \/>\n\u793a\u4f8b\uff1a<br \/>\ncreate table t(id float(6,2));<\/p>\n<h5>DOUBLE(M,D)\uff1a<\/h5>\n<p>\u53cc\u7cbe\u5ea6\u6d6e\u70b9\u6570\u7cbe\u82f1\uff0c\u5360\u75288\u4e2a\u5b57\u8282\u3002REAL\u7c7b\u578b\u662fDOUBLE\u7c7b\u578b\u7684\u4e00\u4e2a\u522b\u540d\u3002<br \/>\n\u793a\u4f8b\uff1a<br \/>\ncreate table t(id double(10,4));\n<\/p><\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u6570\u503c\u7c7b\u578b\u662fMySQL\u6700\u57fa\u672c\u7684\u6570\u636e\u7c7b\u578b\uff0c\u4e5f\u662f\u4f7f\u7528\u6700\u591a\u7684\u7c7b\u578b\uff0c\u4e3b\u8981\u5305\u62ec\u6574\u578b\u3001\u6d6e\u70b9\u578b\u3001\u7cbe\u786e\u6570\u503c\u578b\u7b49\u3002 \u6570\u503c\u7c7b\u578b\uff1a B &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"http:\/\/www.weijing.co\/?p=2047\"> <span class=\"screen-reader-text\">MySQL\u6570\u636e\u7c7b\u578b-\u6570\u503c\u578b<\/span> \u67e5\u770b\u5168\u6587 &raquo;<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":""},"categories":[90,88],"tags":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"mailpoet_newsletter_max":false,"woocommerce_thumbnail":false,"woocommerce_single":false,"woocommerce_gallery_thumbnail":false,"shop_catalog":false,"shop_single":false,"shop_thumbnail":false},"uagb_author_info":{"display_name":"weijing","author_link":"http:\/\/www.weijing.co\/?author=4"},"uagb_comment_info":0,"uagb_excerpt":"\u6570\u503c\u7c7b\u578b\u662fMySQL\u6700\u57fa\u672c\u7684\u6570\u636e\u7c7b\u578b\uff0c\u4e5f\u662f\u4f7f\u7528\u6700\u591a\u7684\u7c7b\u578b\uff0c\u4e3b\u8981\u5305\u62ec\u6574\u578b\u3001\u6d6e\u70b9\u578b\u3001\u7cbe\u786e\u6570\u503c\u578b\u7b49\u3002 \u6570\u503c\u7c7b\u578b\uff1a B&hellip;","_links":{"self":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/2047"}],"collection":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2047"}],"version-history":[{"count":0,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/2047\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2047"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2047"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2047"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}