{"id":743,"date":"2023-02-02T11:28:19","date_gmt":"2023-02-02T03:28:19","guid":{"rendered":"http:\/\/blog.nonot.cn\/?p=743"},"modified":"2024-07-08T12:44:35","modified_gmt":"2024-07-08T04:44:35","slug":"mysql-%e5%b8%b8%e7%94%a8%e7%9a%84%e6%95%b0%e6%8d%ae%e7%b1%bb%e5%9e%8b","status":"publish","type":"post","link":"https:\/\/blog.nonot.cn\/index.php\/2023\/02\/02\/mysql-%e5%b8%b8%e7%94%a8%e7%9a%84%e6%95%b0%e6%8d%ae%e7%b1%bb%e5%9e%8b\/","title":{"rendered":"mysql \u5e38\u7528\u7684\u6570\u636e\u7c7b\u578b"},"content":{"rendered":"<p>\u5e38\u7528\u7684\u6570\u636e\u7c7b\u578b<br \/>\nint<\/p>\n<p>\u6570\u5b57\u8303\u56f4-2**32 ~ 2**32-1<\/p>\n<p>bigint<\/p>\n<p>\u6570\u5b57\u8303\u56f4-2**63 ~ 2 ** 63-1<\/p>\n<p>float<\/p>\n<p>float(m,d), \u5176\u4e2dm\u8868\u793a\u7684\u662f\u6709\u6548\u4f4d, d\u8868\u793a\u5c0f\u6570\u4f4d<br \/>\n\u6709\u6548\u4f4d\u5c31\u662f\u628a\u5f53\u524d\u7684\u5c0f\u6570: 12345.12 \u8f6c\u53d8\u6210\u79d1\u5b66\u8ba1\u6570\u6cd5: 1.234512 * 10**5<br \/>\nm\u6700\u5927\u503c\u4e3a7<\/p>\n<p>double<\/p>\n<p>double(m, d), \u5176\u4e2dm\u8868\u793a\u7684\u662f\u6709\u6548\u4f4d, d\u8868\u793a\u5c0f\u6570\u4f4d<br \/>\nm\u7684\u6700\u5927\u503c\u4e3a15<\/p>\n<p>decimal<\/p>\n<p>\u6d89\u53ca\u91d1\u989d\u7684\u65f6\u5019\u4f7f\u7528decimal.<\/p>\n<p>double(m, d), \u5176\u4e2dm\u8868\u793a\u7684\u662f\u6709\u6548\u4f4d, d\u8868\u793a\u5c0f\u6570\u4f4d<br \/>\nm\u7684\u6700\u5927\u503c\u4e3a65<\/p>\n<p>\u4e0d\u4f1a\u4ea7\u751f\u7cbe\u5ea6\u95ee\u9898, \u56e0\u4e3adecimal\u6ca1\u6709\u7cbe\u5ea6\u635f\u5931\u7684\u672c\u8d28\u662f\u56e0\u4e3a\u5b83\u5b58\u7684\u662f\u5b57\u7b26\u4e32.<\/p>\n<p>char<\/p>\n<p>\u8868\u793a\u56fa\u5b9a\u957f\u5ea6\u7684\u5b57\u7b26\u4e32, \u957f\u5ea6\u4e3a255\u4e2a\u5b57\u8282<\/p>\n<p>\u4e2d\u6587\u5b57\u7b26\u5360\u636e3~4\u4e2a\u5b57\u8282<\/p>\n<p>varchar<\/p>\n<p>\u8868\u793a\u4e0d\u5b9a\u957f\u7684\u5b57\u7b26\u4e32, \u957f\u5ea6\u4e3a0~65535\u4e2a\u5b57\u8282<\/p>\n<p>TEXT<\/p>\n<p>\u957f\u6587\u672c\u7c7b\u578b, \u6700\u5927\u957f\u5ea6\u5360\u636e64kb<\/p>\n<p>datetime<\/p>\n<p>\u5982\u679c\u5f53\u524d\u65f6\u533a\u53d1\u751f\u66f4\u6539, datetime\u7c7b\u578b\u4e0d\u4f1a\u53d1\u751f\u66f4\u6539, \u4e0e\u5b58\u5165\u7684\u65e5\u671f\u4fdd\u6301\u4e00\u81f4.<\/p>\n<p>timestamp<\/p>\n<p>\u5982\u679c\u5f53\u524d\u65f6\u533a\u53d1\u751f\u66f4\u6539, timestamp\u7c7b\u578b\u4f1a\u8ddf\u7740\u65f6\u533a\u66f4\u6539.<\/p>\n<p>\u5e38\u7528\u7684\u8fd0\u7b97\u7b26<br \/>\n\u7b97\u672f\u8fd0\u7b97\u7b26<\/p>\n<p>+<\/p>\n<p>&#8211;<\/p>\n<p>*<\/p>\n<p>\/<\/p>\n<p>div<\/p>\n<p>\u53d6\u5546<\/p>\n<p>SELECT 5 div 3<\/p>\n<p>mod<\/p>\n<p>\u53d6\u4f59<\/p>\n<p>SELECT 5 mod 3<\/p>\n<p>\u6bd4\u8f83\u8fd0\u7b97\u7b26<\/p>\n<p>=<\/p>\n<p>\u7c7b\u4f3cpython\u4e2d\u7684 ==<\/p>\n<p>SELECT 1 =1<\/p>\n<p>!=<\/p>\n<p>&gt; \u4e0e&gt;=<\/p>\n<p>&lt;\u4e0e&lt;=<\/p>\n<p>between \u4e0enot between<\/p>\n<p>SELECT 2 not between 1 and 3<\/p>\n<p>is null \u4e0e is not null<\/p>\n<p>\u7528\u6765\u5224\u65ad\u5f53\u524d\u662f\u5426\u6709\u8bb0\u5f55<\/p>\n<p>\u903b\u8f91\u8fd0\u7b97\u7b26<\/p>\n<p>NOT<br \/>\nAND<br \/>\nOR<br \/>\nXOR(\u4e86\u89e3)<br \/>\n\u5f02\u6216, \u4e24\u4e2a\u503c\u4e00\u4e2aTrue, \u4e00\u4e2a\u4e3aFalse, \u5f53\u524d\u8868\u8fbe\u5f0f\u624d\u4e3aTrue<br \/>\n\u5e38\u7528\u7684\u51fd\u6570<br \/>\n\u7b97\u672f\u8fd0\u7b97<\/p>\n<p>SUM<\/p>\n<p>\u548c<\/p>\n<p>AVG<\/p>\n<p>\u5e73\u5747\u6570<\/p>\n<p>MAX\u548cMIN<\/p>\n<p>\u5bf9\u5b57\u7b26\u4e32\u8fdb\u884c\u64cd\u4f5c\u65f6, \u7c7b\u4f3cpython\u7684\u6392\u5e8f, \u662f\u6839\u636eascii\u7801\u6765\u6392\u5e8f\u7684.<\/p>\n<p>COUNT<\/p>\n<p>\u8ba1\u7b97\u5f53\u524d\u8bb0\u5f55\u6570<br \/>\nSELECT count(*) from test<\/p>\n<p>CHAR_LENGTH \u5b57\u7b26\u5904\u7406<\/p>\n<p>SELECT CHAR_LENGTH(&#8220;test&#8221;)<\/p>\n<p>FORMAT \u683c\u5f0f\u5316<\/p>\n<p>SELECT FORMAT(0.333333,2)<\/p>\n<p>LEFT\u548cRIGHT<\/p>\n<p>SELECT right(&#8220;abcdefg&#8221;, 2)<\/p>\n<p>TRIM<\/p>\n<p>SELECT trim(&#8220;abcdefg &#8220;)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5e38\u7528\u7684\u6570\u636e\u7c7b\u578b int \u6570\u5b57\u8303\u56f4-2**32 ~ 2**32&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-743","post","type-post","status-publish","format-standard","hentry","category-mysql"],"_links":{"self":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts\/743","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/comments?post=743"}],"version-history":[{"count":1,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts\/743\/revisions"}],"predecessor-version":[{"id":1134,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts\/743\/revisions\/1134"}],"wp:attachment":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/media?parent=743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/categories?post=743"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/tags?post=743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}