{"id":18,"date":"2026-03-10T17:31:46","date_gmt":"2026-03-10T09:31:46","guid":{"rendered":"https:\/\/www.loongdi.net\/blog\/?p=18"},"modified":"2026-03-10T17:31:46","modified_gmt":"2026-03-10T09:31:46","slug":"smallint%e5%80%bc%e8%8c%83%e5%9b%b4%e7%9a%84%e6%9c%80%e4%bd%b3%e5%ae%9e%e8%b7%b5%e4%b8%8e%e5%ba%94%e7%94%a8%e5%88%86%e6%9e%90","status":"publish","type":"post","link":"https:\/\/www.loongdi.net\/blog\/18.html","title":{"rendered":"smallint\u503c\u8303\u56f4\u7684\u6700\u4f73\u5b9e\u8df5\u4e0e\u5e94\u7528\u5206\u6790"},"content":{"rendered":"<p><p>\u5728\u6570\u636e\u5e93\u7cfb\u7edf\u4e2d\uff0csmallint\u662f\u4e00\u79cd\u7528\u4e8e\u5b58\u50a8\u6574\u6570\u7684\u6570\u503c\u6570\u636e\u7c7b\u578b\u3002\u5176\u503c\u8303\u56f4\u901a\u5e38\u4e3a-32,768\u523032,767\u3002\u6839\u636e\u4e0d\u540c\u7684\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\uff0csmallint\u7684\u5177\u4f53\u5b9e\u73b0\u53ef\u80fd\u4f1a\u6709\u7ec6\u5fae\u7684\u5dee\u522b\uff0c\u4f46\u4e00\u822c\u90fd\u9075\u5faa\u8fd9\u4e2a\u8303\u56f4\u3002\u4f7f\u7528smallint\u7c7b\u578b\u53ef\u4ee5\u6709\u6548\u51cf\u5c11\u5b58\u50a8\u7a7a\u95f4\uff0c\u9002\u5408\u4e00\u4e9b\u5bf9\u6570\u503c\u8981\u6c42\u4e0d\u9ad8\u7684\u573a\u666f\u3002<\/p>\n<\/p>\n<p>\n<h3>1. smallint\u7684\u57fa\u672c\u5b9a\u4e49<\/h3>\n<\/p>\n<p>smallint\u662f\u4e00\u79cd\u77ed\u6574\u578b\u6570\u636e\uff0c\u901a\u5e38\u5360\u7528\u4e24\u4e2a\u5b57\u8282\u7684\u5185\u5b58\u3002\u5728\u5173\u7cfb\u578b\u6570\u636e\u5e93\u4e2d\uff0c\u4f8b\u5982MySQL\u3001PostgreSQL\u548cSQL Server\uff0csmallint\u5e7f\u6cdb\u7528\u4e8e\u5b58\u50a8\u5c0f\u8303\u56f4\u7684\u6574\u6570\u503c\u3002\u7531\u4e8e\u5176\u5360\u7528\u7684\u7a7a\u95f4\u8f83\u5c0f\uff0c\u4f7f\u7528smallint\u4e0d\u4ec5\u63d0\u9ad8\u4e86\u6570\u636e\u5e93\u7684\u6027\u80fd\uff0c\u4e5f\u51cf\u5c11\u4e86\u6570\u636e\u5b58\u50a8\u7684\u5f00\u9500\u3002<\/p>\n<p>\u5bf9\u4e8e\u9700\u8981\u5b58\u50a8\u5927\u8303\u56f4\u6574\u6570\u503c\u7684\u5e94\u7528\uff0c\u4f7f\u7528int\u6216bigint\u5c06\u662f\u66f4\u5408\u9002\u7684\u9009\u62e9\u3002\u7136\u800c\uff0c\u5982\u679c\u53ea\u9700\u5904\u7406\u5c0f\u6570\u503c\uff0c\u6bd4\u5982\u8ba1\u6570\u5668\u3001\u72b6\u6001\u6807\u5fd7\u6216\u5176\u4ed6\u9700\u8981\u4f7f\u7528\u5c0f\u6570\u5b57\u7684\u5b57\u6bb5\uff0csmallint\u5c31\u662f\u66f4\u597d\u7684\u9009\u9879\u3002<\/p>\n<\/p>\n<p>\n<h3>2. \u5177\u4f53\u503c\u8303\u56f4\u53ca\u5e94\u7528<\/h3>\n<\/p>\n<p>smallint\u7684\u503c\u8303\u56f4\u662f\u4ece-32,768\u523032,767\u3002\u5728\u8bb8\u591a\u5e94\u7528\u4e2d\uff0c\u8fd9\u4e2a\u8303\u56f4\u8db3\u4ee5\u6ee1\u8db3\u5927\u591a\u6570\u9700\u6c42\uff0c\u7279\u522b\u662f\u5728\u9700\u8981\u5b58\u50a8\u57ce\u5e02\u4eba\u53e3\u3001\u4ea7\u54c1\u6570\u91cf\u6216\u7b80\u5355\u7684\u72b6\u6001\u6807\u5fd7\u7b49\u573a\u666f\u65f6\u3002<\/p>\n<p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u67d0\u4e9b\u573a\u5408\u9700\u907f\u514d\u8d85\u51fa\u6b64\u8303\u56f4\uff0c\u5c24\u5176\u662f\u5728\u6570\u636e\u8fc1\u79fb\u6216\u8f6c\u6362\u65f6\uff0c\u53ef\u80fd\u4f1a\u53d1\u751f\u6ea2\u51fa\u9519\u8bef\u3002\u4e3a\u4e86\u907f\u514d\u8fd9\u6837\u7684\u60c5\u51b5\uff0c\u5f00\u53d1\u8005\u5e94\u59cb\u7ec8\u4fdd\u6301\u6570\u503c\u5728\u9884\u8bbe\u8303\u56f4\u5185\u3002\u53e6\u5916\uff0c\u53ef\u4ee5\u901a\u8fc7\u6570\u636e\u5e93\u7ea6\u675f\u6765\u4fdd\u8bc1\u6570\u636e\u7684\u4e00\u81f4\u6027\u3002<\/p>\n<\/p>\n<p>\n<h3>3. \u5f53smallint\u4e0d\u8db3\u4ee5\u6ee1\u8db3\u9700\u6c42\u65f6<\/h3>\n<\/p>\n<p>\u867d\u7136smallint\u5728\u5f88\u591a\u60c5\u51b5\u4e2d\u90fd\u80fd\u6ee1\u8db3\u9700\u6c42\uff0c\u4f46\u4e5f\u6709\u4e00\u4e9b\u5e94\u7528\u573a\u666f\u4f1a\u8d85\u51fa\u8fd9\u4e2a\u8303\u56f4\u3002\u4f8b\u5982\uff0c\u5f53\u9700\u8981\u5b58\u50a8\u7528\u6237\u7684\u8ba2\u5355\u6570\u91cf\u6216\u516c\u53f8\u5458\u5de5\u6570\u91cf\u7b49\u65f6\uff0c\u53ef\u80fd\u4f1a\u9700\u8981\u66f4\u5927\u7684\u6570\u636e\u7c7b\u578b\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528int\u7c7b\u578b\u3002<\/p>\n<p>int\u7c7b\u578b\u7684\u8303\u56f4\u4ece-2,147,483,648\u52302,147,483,647\uff0c\u662fsmallint\u768464\u500d\u3002\u56e0\u6b64\uff0c\u9009\u62e9\u5408\u9002\u7684\u6570\u636e\u7c7b\u578b\u5bf9\u4e8e\u786e\u4fdd\u6570\u636e\u7684\u51c6\u786e\u6027\u548c\u5b8c\u6574\u6027\u81f3\u5173\u91cd\u8981\u3002\u4e3a\u4e86\u63d0\u9ad8\u6027\u80fd\u548c\u5b58\u50a8\u6548\u7387\uff0c\u5efa\u8bae\u5728\u8bbe\u8ba1\u6570\u636e\u5e93\u65f6\u6df1\u5165\u4e86\u89e3\u5404\u6570\u636e\u7c7b\u578b\u7684\u7279\u6027\u3002<\/p>\n<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.loongdi.net\/blog\/wp-content\/uploads\/2026\/03\/0NdkL.jpg\" alt=\"smallint\u503c\u8303\u56f4\u7684\u6700\u4f73\u5b9e\u8df5\u4e0e\u5e94\u7528\u5206\u6790\" title=\"smallint\u503c\u8303\u56f4\u7684\u6700\u4f73\u5b9e\u8df5\u4e0e\u5e94\u7528\u5206\u6790\"><\/p>\n<p>\n<h3>4. \u4e3a\u4ec0\u4e48\u8981\u4f7f\u7528smallint\uff1f<\/h3>\n<\/p>\n<p><b>\u4f7f\u7528smallint\u7684\u597d\u5904\u662f\u4ec0\u4e48\uff1f<\/b> \u5c0f\u578b\u6574\u6570\u7c7b\u578b\u5c0f\uff0c\u5360\u7528\u6570\u636e\u5e93\u5b58\u50a8\u7a7a\u95f4\u5c11\u3002\u5bf9\u4e8e\u53ea\u9700\u5c0f\u6570\u503c\u7684\u573a\u666f\uff0c\u6bd4\u5982\u72b6\u6001\u503c\u6216\u8ba1\u6570\u5668\u4f7f\u7528smallint\u53ef\u4ee5\u63d0\u9ad8\u6027\u80fd\uff0c\u800c\u4e14\u80fd\u6709\u6548\u5229\u7528\u5927\u5bb9\u91cf\u6570\u636e\u5e93\u7cfb\u7edf\u7684\u5b58\u50a8\u7a7a\u95f4\u3002<\/p>\n<p><b>\u5728\u4ec0\u4e48\u60c5\u51b5\u4e0b\u9002\u5408\u9009\u62e9smallint\uff1f<\/b> smallint\u9002\u5408\u5728\u9700\u8981\u5b58\u50a8\u7684\u6570\u503c\u4e25\u683c\u5728-32,768\u523032,767\u4e4b\u95f4\u65f6\u4f7f\u7528\uff0c\u6bd4\u5982\u5728\u8bb0\u5f55\u4ea7\u54c1\u5e93\u5b58\u6216\u8005\u7528\u6237\u884c\u4e3a\u7edf\u8ba1\u7b49\u65b9\u9762\uff0c\u5c24\u5176\u662f\u5728\u5bf9\u6027\u80fd\u6709\u8981\u6c42\u7684\u60c5\u51b5\u4e0b\u3002<\/p>\n<p><b>smallint\u7684\u503c\u8303\u56f4\u80fd\u5426\u6ee1\u8db3\u672a\u6765\u53d1\u5c55\u9700\u8981\uff1f<\/b> \u5982\u679c\u9884\u8ba1\u672a\u6765\u9700\u8981\u5b58\u50a8\u66f4\u5927\u7684\u6570\u503c\uff0c\u5efa\u8bae\u5728\u8bbe\u8ba1\u6570\u636e\u5e93\u4e4b\u521d\u5c31\u9009\u62e9\u4e00\u4e2a\u66f4\u5927\u7684\u6570\u636e\u7c7b\u578b\uff0c\u4f8b\u5982int\uff0c\u4ee5\u907f\u514d\u5f15\u53d1\u6570\u636e\u6ea2\u51fa\u7684\u95ee\u9898\u3002<\/p>\n<\/p>\n<p>\n<h3>5. \u907f\u514d\u4f7f\u7528smallint\u7684\u8bef\u533a<\/h3>\n<\/p>\n<p>\u5728\u9009\u62e9\u6570\u636e\u7c7b\u578b\u65f6\uff0c\u6709\u4e9b\u5f00\u53d1\u8005\u53ef\u80fd\u4e0d\u7ecf\u8fc7\u6df1\u601d\u719f\u8651\u5c31\u4f7f\u7528smallint\u3002\u867d\u7136\u5176\u5177\u6709\u4e00\u5b9a\u7684\u4f18\u52bf\uff0c\u4f46\u5982\u679c\u9047\u5230\u5e94\u7528\u89c4\u6a21\u7684\u5feb\u901f\u63d0\u5347\uff0csmallint\u5c31\u53ef\u80fd\u65e0\u6cd5\u6ee1\u8db3\u5176\u9700\u6c42\u3002<\/p>\n<p><b>\u6709\u54ea\u4e9b\u5e38\u89c1\u7684\u8bef\u533a\u9700\u8981\u907f\u514d\uff1f<\/b> \u5c06\u6240\u6709\u6570\u503c\u90fd\u8bbe\u4e3asmallint\u662f\u4e00\u4e2a\u5e38\u89c1\u7684\u9519\u8bef\u3002\u5f00\u53d1\u8005\u5e94\u8be5\u6839\u636e\u4e0d\u540c\u7684\u6570\u636e\u9700\u6c42\u9009\u62e9\u9002\u5408\u7684\u6570\u636e\u7c7b\u578b\uff0c\u907f\u514d\u672a\u6765\u51fa\u73b0\u6ea2\u51fa\u6216\u6570\u636e\u4e22\u5931\u60c5\u51b5\u3002<\/p>\n<p><b>\u5982\u4f55\u5408\u7406\u89c4\u5212\u6570\u636e\u7c7b\u578b\uff1f<\/b> \u5728\u5e94\u7528\u5f00\u53d1\u4e4b\u524d\uff0c\u8fdb\u884c\u4e00\u6b21\u8be6\u7ec6\u7684\u6570\u636e\u5206\u6790\u4e0e\u9700\u6c42\u8bc4\u4f30\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u660e\u786e\u6570\u636e\u7684\u4f7f\u7528\u9891\u7387\u3001\u8303\u56f4\u548c\u7279\u5f81\uff0c\u8fd9\u5c06\u6709\u52a9\u4e8e\u9009\u62e9\u5408\u9002\u7684\u6570\u636e\u7c7b\u578b\uff0c\u786e\u4fdd\u6709\u6548\u7684\u5b58\u50a8\u4e0e\u8fd0\u884c\u6548\u7387\u3002<\/p>\n<\/p>\n<p>\n<h3>6. smallint\u5728\u4e0d\u540c\u6570\u636e\u5e93\u4e2d\u7684\u8868\u73b0<\/h3>\n<\/p>\n<p>\u4e0d\u540c\u6570\u636e\u5e93\u7cfb\u7edf\u5bf9smallint\u7684\u5b9e\u73b0\u548c\u8868\u73b0\u53ef\u80fd\u4f1a\u6709\u6240\u4e0d\u540c\u3002\u5728MySQL\u4e2d\uff0csmallint\u8303\u56f4\u662f-32,768\u523032,767\uff0c\u800c\u5728SQL Server\u4e2d\uff0csmallint\u4e5f\u540c\u6837\u7ef4\u6301\u8fd9\u4e2a\u6807\u51c6\u3002\u5c3d\u7ba1\u5982\u6b64\uff0c\u5b83\u4eec\u5bf9\u5b58\u50a8\u548c\u6027\u80fd\u7684\u5904\u7406\u53ef\u80fd\u4f1a\u6709\u5dee\u5f02\u3002<\/p>\n<p><b>MySQL\u4e2d\u4f7f\u7528smallint\u7684\u7279\u6027\u662f\u4ec0\u4e48\uff1f<\/b> \u5728MySQL\u4e2d\uff0csmallint\u53ef\u4ee5\u901a\u8fc7\u7279\u5b9a\u9009\u9879\u8fdb\u884c\u65e0\u7b26\u53f7\u5904\u7406\uff0c\u8303\u56f4\u6269\u5c55\u52300\u523065,535\uff0c\u8fd9\u4e3a\u5e94\u7528\u7a0b\u5e8f\u63d0\u4f9b\u4e86\u66f4\u591a\u7684\u7075\u6d3b\u6027\u3002\u5177\u4f53\u4f7f\u7528\u65f6\uff0c\u53ef\u4ee5\u67e5\u770bMySQL\u6587\u6863\u6765\u83b7\u53d6\u66f4\u8be6\u7ec6\u7684\u4fe1\u606f\u548c\u4f18\u5316\u5efa\u8bae\u3002<\/p>\n<p><b>\u5728PostgreSQL\u4e2d\uff0csmallint\u4e0e\u5176\u4ed6\u6574\u578b\u6709\u4ec0\u4e48\u4e0d\u540c\uff1f<\/b> PostgreSQL\u540c\u6837\u9075\u5faasmallint\u7684\u57fa\u672c\u6807\u51c6\uff0c\u4e0d\u8fc7\u5b83\u5141\u8bb8\u66f4\u7075\u6d3b\u7684\u6570\u636e\u7c7b\u578b\u548c\u590d\u6742\u7684\u6570\u636e\u7ed3\u6784\uff0c\u4f7f\u5f97\u5728\u8bbe\u8ba1\u4e0a\u53ef\u4ee5\u66f4\u5177\u521b\u65b0\u6027\u3002\u5f00\u53d1\u8005\u5e94\u6839\u636e\u5b9e\u9645\u9700\u6c42\u9009\u62e9\u76f8\u5e94\u7684\u6570\u636e\u7c7b\u578b\u3002<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u6570\u636e\u5e93\u7cfb\u7edf\u4e2d\uff0csmallint\u662f\u4e00\u79cd\u7528\u4e8e\u5b58\u50a8\u6574\u6570\u7684\u6570\u503c\u6570\u636e\u7c7b\u578b\u3002\u5176\u503c\u8303\u56f4\u901a\u5e38\u4e3a-32,768\u523032,767\u3002\u6839\u636e\u4e0d\u540c\u7684\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\uff0csmallint\u7684\u5177\u4f53\u5b9e\u73b0\u53ef\u80fd\u4f1a\u6709\u7ec6\u5fae\u7684\u5dee\u522b\uff0c\u4f46\u4e00\u822c\u90fd\u9075\u5faa\u8fd9\u4e2a\u8303\u56f4\u3002\u4f7f\u7528smallint\u7c7b\u578b\u53ef\u4ee5\u6709\u6548\u51cf\u5c11&#8230;<\/p>\n","protected":false},"author":1,"featured_media":19,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"topic":[],"class_list":["post-18","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hw"],"_links":{"self":[{"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/posts\/18","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/comments?post=18"}],"version-history":[{"count":1,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/posts\/18\/revisions"}],"predecessor-version":[{"id":20,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/posts\/18\/revisions\/20"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/media\/19"}],"wp:attachment":[{"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/media?parent=18"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/categories?post=18"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/tags?post=18"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/topic?post=18"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}