{"id":71199,"date":"2024-10-15T14:49:17","date_gmt":"2024-10-15T06:49:17","guid":{"rendered":"https:\/\/server.hk\/cnblog\/71199\/"},"modified":"2024-10-15T14:49:17","modified_gmt":"2024-10-15T06:49:17","slug":"mssql%e4%b8%ad%e7%94%a8%e4%bb%80%e9%ba%bc%e6%95%b8%e6%93%9a%e9%a1%9e%e5%9e%8b%e4%be%86%e5%84%b2%e5%ad%98%e6%95%b8%e5%ad%97%ef%bc%88mssql%e6%95%b8%e5%ad%97%e7%94%a8%e4%bb%80%e9%ba%bc%e5%ad%97%e6%ae%b5","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/71199\/","title":{"rendered":"MSSQL\u4e2d\u7528\u4ec0\u9ebc\u6578\u64da\u985e\u578b\u4f86\u5132\u5b58\u6578\u5b57\uff08mssql\u6578\u5b57\u7528\u4ec0\u9ebc\u5b57\u6bb5\uff09"},"content":{"rendered":"<h1 id=\"mssql%e4%b8%ad%e7%94%a8%e4%bb%80%e9%ba%bc%e6%95%b8%e6%93%9a%e9%a1%9e%e5%9e%8b%e4%be%86%e5%84%b2%e5%ad%98%e6%95%b8%e5%ad%97%ef%bc%88mssql%e6%95%b8%e5%ad%97%e7%94%a8%e4%bb%80%e9%ba%bc%e5%ad%97%e6%ae%b5-WBkrChUJmQ\">MSSQL\u4e2d\u7528\u4ec0\u9ebc\u6578\u64da\u985e\u578b\u4f86\u5132\u5b58\u6578\u5b57\uff08mssql\u6578\u5b57\u7528\u4ec0\u9ebc\u5b57\u6bb5\uff09<\/h1>\n<p>\u5728Microsoft SQL Server\uff08MSSQL\uff09\u4e2d\uff0c\u9078\u64c7\u5408\u9069\u7684\u6578\u64da\u985e\u578b\u4f86\u5132\u5b58\u6578\u5b57\u662f\u975e\u5e38\u91cd\u8981\u7684\uff0c\u56e0\u70ba\u9019\u4e0d\u50c5\u5f71\u97ff\u6578\u64da\u7684\u5b58\u5132\u6548\u7387\uff0c\u9084\u6703\u5f71\u97ff\u67e5\u8a62\u6027\u80fd\u548c\u6578\u64da\u7684\u6e96\u78ba\u6027\u3002\u672c\u6587\u5c07\u63a2\u8a0eMSSQL\u4e2d\u53ef\u7528\u7684\u6578\u5b57\u6578\u64da\u985e\u578b\uff0c\u4e26\u63d0\u4f9b\u4e00\u4e9b\u5be6\u7528\u7684\u793a\u4f8b\u548c\u5efa\u8b70\u3002<\/p>\n<h2 id=\"mssql%e4%b8%ad%e7%9a%84%e6%95%b8%e5%ad%97%e6%95%b8%e6%93%9a%e9%a1%9e%e5%9e%8b-WBkrChUJmQ\">MSSQL\u4e2d\u7684\u6578\u5b57\u6578\u64da\u985e\u578b<\/h2>\n<p>MSSQL\u63d0\u4f9b\u4e86\u591a\u7a2e\u6578\u64da\u985e\u578b\u4f86\u5132\u5b58\u6578\u5b57\uff0c\u4e3b\u8981\u53ef\u4ee5\u5206\u70ba\u6574\u6578\u985e\u578b\u548c\u6d6e\u9ede\u6578\u985e\u578b\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u6578\u64da\u985e\u578b\uff1a<\/p>\n<ul>\n<li><strong>\u6574\u6578\u985e\u578b\uff1a<\/strong>\n<ul>\n<li><code>TINYINT<\/code>\uff1a\u7bc4\u570d\u662f0\u5230255\uff0c\u4f54\u75281\u500b\u5b57\u7bc0\u3002<\/li>\n<li><code>SMALLINT<\/code>\uff1a\u7bc4\u570d\u662f-32,768\u523032,767\uff0c\u4f54\u75282\u500b\u5b57\u7bc0\u3002<\/li>\n<li><code>INT<\/code>\uff1a\u7bc4\u570d\u662f-2,147,483,648\u52302,147,483,647\uff0c\u4f54\u75284\u500b\u5b57\u7bc0\u3002<\/li>\n<li><code>BIGINT<\/code>\uff1a\u7bc4\u570d\u662f-9,223,372,036,854,775,808\u52309,223,372,036,854,775,807\uff0c\u4f54\u75288\u500b\u5b57\u7bc0\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u6d6e\u9ede\u6578\u985e\u578b\uff1a<\/strong>\n<ul>\n<li><code>FLOAT<\/code>\uff1a\u53ef\u5132\u5b58\u7684\u6578\u5b57\u7bc4\u570d\u975e\u5e38\u5927\uff0c\u4f54\u75284\u62168\u500b\u5b57\u7bc0\uff0c\u5177\u9ad4\u53d6\u6c7a\u65bc\u7cbe\u5ea6\u3002<\/li>\n<li><code>REAL<\/code>\uff1a\u7bc4\u570d\u662f-3.402823E+38\u52303.402823E+38\uff0c\u4f54\u75284\u500b\u5b57\u7bc0\u3002<\/li>\n<li><code>DECIMAL(p, s)<\/code>\uff1a\u7cbe\u78ba\u7684\u6578\u5b57\u985e\u578b\uff0c<code>p<\/code>\u8868\u793a\u7e3d\u4f4d\u6578\uff0c<code>s<\/code>\u8868\u793a\u5c0f\u6578\u4f4d\u6578\uff0c\u4f54\u7528\u7684\u5b57\u7bc0\u6578\u53d6\u6c7a\u65bc<code>p<\/code>\u7684\u503c\u3002<\/li>\n<li><code>MONEY<\/code>\u548c<code>SMALLMONEY<\/code>\uff1a\u5c08\u9580\u7528\u65bc\u5132\u5b58\u8ca8\u5e63\u503c\uff0c<code>MONEY<\/code>\u4f54\u75288\u500b\u5b57\u7bc0\uff0c<code>SMALLMONEY<\/code>\u4f54\u75284\u500b\u5b57\u7bc0\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2 id=\"%e9%81%b8%e6%93%87%e5%90%88%e9%81%a9%e7%9a%84%e6%95%b8%e6%93%9a%e9%a1%9e%e5%9e%8b-WBkrChUJmQ\">\u9078\u64c7\u5408\u9069\u7684\u6578\u64da\u985e\u578b<\/h2>\n<p>\u9078\u64c7\u5408\u9069\u7684\u6578\u64da\u985e\u578b\u53d6\u6c7a\u65bc\u591a\u500b\u56e0\u7d20\uff0c\u5305\u62ec\u6578\u64da\u7684\u7bc4\u570d\u3001\u7cbe\u5ea6\u8981\u6c42\u548c\u5b58\u5132\u6548\u7387\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u9078\u64c7\u5efa\u8b70\uff1a<\/p>\n<ul>\n<li>\u5982\u679c\u60a8\u53ea\u9700\u8981\u5132\u5b58\u5c0f\u7bc4\u570d\u7684\u6574\u6578\uff0c<code>TINYINT<\/code>\u6216<code>SMALLINT<\/code>\u53ef\u80fd\u662f\u5408\u9069\u7684\u9078\u64c7\u3002<\/li>\n<li>\u5c0d\u65bc\u5927\u7bc4\u570d\u7684\u6574\u6578\uff0c<code>INT<\/code>\u6216<code>BIGINT<\/code>\u662f\u66f4\u597d\u7684\u9078\u64c7\u3002<\/li>\n<li>\u5982\u679c\u9700\u8981\u5132\u5b58\u5e36\u6709\u5c0f\u6578\u7684\u6578\u5b57\uff0c<code>DECIMAL<\/code>\u985e\u578b\u63d0\u4f9b\u4e86\u66f4\u9ad8\u7684\u7cbe\u5ea6\uff0c\u9069\u5408\u8ca1\u52d9\u8a08\u7b97\u3002<\/li>\n<li>\u5c0d\u65bc\u9700\u8981\u6d6e\u52d5\u7cbe\u5ea6\u7684\u6578\u5b57\uff0c<code>FLOAT<\/code>\u6216<code>REAL<\/code>\u53ef\u4ee5\u8003\u616e\uff0c\u4f46\u9700\u6ce8\u610f\u5176\u7cbe\u5ea6\u554f\u984c\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%a4%ba%e4%be%8b-WBkrChUJmQ\">\u793a\u4f8b<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e9b\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u5728MSSQL\u4e2d\u5275\u5efa\u8868\u4e26\u4f7f\u7528\u4e0d\u540c\u7684\u6578\u64da\u985e\u578b\uff1a<\/p>\n<pre><code>CREATE TABLE Products (\n    ProductID INT PRIMARY KEY,\n    ProductName NVARCHAR(100),\n    Price DECIMAL(10, 2),\n    Stock TINYINT\n);\n<\/code><\/pre>\n<p>\u5728\u9019\u500b\u793a\u4f8b\u4e2d\uff0c<code>ProductID<\/code>\u4f7f\u7528<code>INT<\/code>\u985e\u578b\uff0c<code>Price<\/code>\u4f7f\u7528<code>DECIMAL<\/code>\u985e\u578b\u4ee5\u78ba\u4fdd\u50f9\u683c\u7684\u7cbe\u78ba\u6027\uff0c\u800c<code>Stock<\/code>\u4f7f\u7528<code>TINYINT<\/code>\u4f86\u5132\u5b58\u5eab\u5b58\u6578\u91cf\u3002<\/p>\n<h2 id=\"%e7%b5%90%e8%ab%96-WBkrChUJmQ\">\u7d50\u8ad6<\/h2>\n<p>\u5728MSSQL\u4e2d\uff0c\u9078\u64c7\u5408\u9069\u7684\u6578\u64da\u985e\u578b\u4f86\u5132\u5b58\u6578\u5b57\u662f\u8a2d\u8a08\u6578\u64da\u5eab\u6642\u7684\u4e00\u500b\u91cd\u8981\u8003\u91cf\u3002\u6839\u64da\u6578\u64da\u7684\u7bc4\u570d\u548c\u7cbe\u5ea6\u9700\u6c42\uff0c\u9078\u64c7\u5408\u9069\u7684\u6574\u6578\u6216\u6d6e\u9ede\u6578\u985e\u578b\u53ef\u4ee5\u63d0\u9ad8\u5b58\u5132\u6548\u7387\u548c\u67e5\u8a62\u6027\u80fd\u3002\u4e86\u89e3\u5404\u7a2e\u6578\u64da\u985e\u578b\u7684\u7279\u6027\u548c\u4f7f\u7528\u5834\u666f\uff0c\u5c07\u6709\u52a9\u65bc\u958b\u767c\u8005\u5728\u8a2d\u8a08\u6578\u64da\u5eab\u6642\u505a\u51fa\u66f4\u660e\u667a\u7684\u6c7a\u7b56\u3002<\/p>\n<p>\u5982\u9700\u4e86\u89e3\u66f4\u591a\u95dc\u65bc<code>VPS<\/code>\u3001<code>\u9999\u6e2fVPS<\/code>\u3001<code>\u670d\u52a1\u5668<\/code>\u3001<code>\u4e91\u670d\u52a1\u5668<\/code>\u7b49\u8cc7\u8a0a\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9 <a href=\"https:\/\/server.hk\">Server.HK<\/a>\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3MSSQL\u4e2d\u5132\u5b58\u6578\u5b57\u7684\u6578\u64da\u985e\u578b\uff0c\u5305\u62ecINT\u3001FLOAT\u3001DECIMAL\u7b49\uff0c\u9078\u64c7\u5408\u9069\u5b57\u6bb5\u4ee5\u6eff\u8db3\u4e0d\u540c\u9700\u6c42\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-71199","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/71199","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=71199"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/71199\/revisions"}],"predecessor-version":[{"id":71200,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/71199\/revisions\/71200"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=71199"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=71199"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=71199"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}