{"id":137191,"date":"2024-10-31T12:09:24","date_gmt":"2024-10-31T04:09:24","guid":{"rendered":"https:\/\/server.hk\/cnblog\/137191\/"},"modified":"2024-10-31T12:09:25","modified_gmt":"2024-10-31T04:09:25","slug":"sql-server-bit%e9%a1%9e%e5%9e%8b%e8%83%bd%e5%8d%a0%e5%a4%9a%e5%b0%91%e7%a9%ba%e9%96%93%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/137191\/","title":{"rendered":"SQL Server BIT\u985e\u578b\u80fd\u5360\u591a\u5c11\u7a7a\u9593\uff1f"},"content":{"rendered":"<h1 id=\"sql-server-bit%e9%a1%9e%e5%9e%8b%e8%83%bd%e5%8d%a0%e5%a4%9a%e5%b0%91%e7%a9%ba%e9%96%93%ef%bc%9f-DbFgQAPnIS\">SQL Server BIT\u985e\u578b\u80fd\u5360\u591a\u5c11\u7a7a\u9593\uff1f<\/h1>\n<p>\u5728\u8cc7\u6599\u5eab\u8a2d\u8a08\u4e2d\uff0c\u9078\u64c7\u5408\u9069\u7684\u8cc7\u6599\u985e\u578b\u5c0d\u65bc\u6027\u80fd\u548c\u5b58\u5132\u6548\u7387\u81f3\u95dc\u91cd\u8981\u3002SQL Server\u63d0\u4f9b\u4e86\u591a\u7a2e\u8cc7\u6599\u985e\u578b\uff0c\u5176\u4e2dBIT\u985e\u578b\u662f\u4e00\u500b\u5e38\u7528\u7684\u9078\u64c7\uff0c\u7279\u5225\u662f\u5728\u9700\u8981\u5132\u5b58\u5e03\u6797\u503c\uff08\u771f\u6216\u5047\uff09\u6642\u3002\u90a3\u9ebc\uff0cSQL Server\u4e2d\u7684BIT\u985e\u578b\u7a76\u7adf\u80fd\u5360\u7528\u591a\u5c11\u7a7a\u9593\u5462\uff1f\u672c\u6587\u5c07\u6df1\u5165\u63a2\u8a0e\u9019\u4e00\u554f\u984c\u3002<\/p>\n<h2 id=\"bit%e9%a1%9e%e5%9e%8b%e7%9a%84%e5%9f%ba%e6%9c%ac%e6%a6%82%e5%bf%b5-DbFgQAPnIS\">BIT\u985e\u578b\u7684\u57fa\u672c\u6982\u5ff5<\/h2>\n<p>\u5728SQL Server\u4e2d\uff0cBIT\u985e\u578b\u7528\u65bc\u5132\u5b58\u5e03\u6797\u503c\u3002\u5b83\u53ef\u4ee5\u5132\u5b58\u4e09\u7a2e\u72c0\u614b\uff1a0\uff08\u5047\uff09\u30011\uff08\u771f\uff09\u548cNULL\uff08\u672a\u77e5\uff09\u3002\u9019\u4f7f\u5f97BIT\u985e\u578b\u975e\u5e38\u9069\u5408\u7528\u65bc\u9700\u8981\u8868\u793a\u4e8c\u5143\u72c0\u614b\u7684\u60c5\u6cc1\uff0c\u4f8b\u5982\u7528\u6236\u662f\u5426\u555f\u7528\u67d0\u500b\u529f\u80fd\u3001\u8a02\u55ae\u662f\u5426\u5df2\u5b8c\u6210\u7b49\u3002<\/p>\n<h2 id=\"bit%e9%a1%9e%e5%9e%8b%e7%9a%84%e5%ad%98%e5%84%b2%e7%a9%ba%e9%96%93-DbFgQAPnIS\">BIT\u985e\u578b\u7684\u5b58\u5132\u7a7a\u9593<\/h2>\n<p>\u6839\u64daSQL Server\u7684\u5b98\u65b9\u6587\u6a94\uff0cBIT\u985e\u578b\u7684\u5b58\u5132\u7a7a\u9593\u53d6\u6c7a\u65bc\u5132\u5b58\u7684\u6578\u91cf\u3002\u5177\u9ad4\u4f86\u8aaa\uff1a<\/p>\n<ul>\n<li>\u5982\u679c\u4e00\u500b\u8868\u4e2d\u53ea\u6709\u4e00\u500bBIT\u5217\uff0c\u5247\u8a72\u5217\u5c07\u4f54\u75281\u500b\u4f4d\u5143\uff08bit\uff09\uff0c\u53730.125\u500b\u5b57\u7bc0\u3002<\/li>\n<li>\u5982\u679c\u6709\u591a\u500bBIT\u5217\uff0cSQL Server\u6703\u5c07\u5b83\u5011\u6253\u5305\u5728\u4e00\u8d77\u3002\u6bcf8\u500bBIT\u5217\u5c07\u4f54\u75281\u500b\u5b57\u7bc0\u3002\u56e0\u6b64\uff0c2\u52308\u500bBIT\u5217\u5c07\u4f54\u75281\u500b\u5b57\u7bc0\uff0c9\u523016\u500bBIT\u5217\u5c07\u4f54\u75282\u500b\u5b57\u7bc0\uff0c\u4ee5\u6b64\u985e\u63a8\u3002<\/li>\n<\/ul>\n<p>\u9019\u610f\u5473\u8457\uff0c\u5118\u7ba1BIT\u985e\u578b\u7684\u7406\u8ad6\u4e0a\u53ea\u97001\u4f4d\u5143\uff0c\u4f46\u5be6\u969b\u4e0a\u5728\u5132\u5b58\u6642\u6703\u6839\u64da\u5217\u7684\u6578\u91cf\u9032\u884c\u6253\u5305\uff0c\u5f9e\u800c\u5f71\u97ff\u7e3d\u7684\u5b58\u5132\u7a7a\u9593\u3002<\/p>\n<h2 id=\"bit%e9%a1%9e%e5%9e%8b%e7%9a%84%e4%bd%bf%e7%94%a8%e7%af%84%e4%be%8b-DbFgQAPnIS\">BIT\u985e\u578b\u7684\u4f7f\u7528\u7bc4\u4f8b<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u500b\u7c21\u55ae\u7684\u7bc4\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u5728SQL Server\u4e2d\u4f7f\u7528BIT\u985e\u578b\uff1a<\/p>\n<pre><code>CREATE TABLE Users (\n    UserID INT PRIMARY KEY,\n    UserName NVARCHAR(50),\n    IsActive BIT\n);\n\nINSERT INTO Users (UserID, UserName, IsActive) VALUES (1, 'Alice', 1);\nINSERT INTO Users (UserID, UserName, IsActive) VALUES (2, 'Bob', 0);\n<\/code><\/pre>\n<p>\u5728\u9019\u500b\u7bc4\u4f8b\u4e2d\uff0c\u6211\u5011\u5275\u5efa\u4e86\u4e00\u500b\u540d\u70baUsers\u7684\u8868\uff0c\u5176\u4e2d\u5305\u542b\u4e00\u500bBIT\u985e\u578b\u7684\u5217IsActive\uff0c\u7528\u65bc\u8868\u793a\u7528\u6236\u662f\u5426\u6d3b\u8e8d\u3002\u9019\u6a23\u7684\u8a2d\u8a08\u4e0d\u50c5\u7c21\u6f54\uff0c\u800c\u4e14\u6709\u6548\u5730\u5229\u7528\u4e86\u5b58\u5132\u7a7a\u9593\u3002<\/p>\n<h2 id=\"bit%e9%a1%9e%e5%9e%8b%e7%9a%84%e5%84%aa%e7%bc%ba%e9%bb%9e-DbFgQAPnIS\">BIT\u985e\u578b\u7684\u512a\u7f3a\u9ede<\/h2>\n<h3 id=\"%e5%84%aa%e9%bb%9e-DbFgQAPnIS\">\u512a\u9ede<\/h3>\n<ul>\n<li>\u7bc0\u7701\u7a7a\u9593\uff1a\u76f8\u8f03\u65bc\u4f7f\u7528\u6574\u6578\u6216\u5b57\u5143\u578b\u5225\uff0cBIT\u985e\u578b\u80fd\u5920\u6709\u6548\u5730\u7bc0\u7701\u5b58\u5132\u7a7a\u9593\u3002<\/li>\n<li>\u7c21\u55ae\u6613\u7528\uff1a\u4f7f\u7528BIT\u985e\u578b\u53ef\u4ee5\u6e05\u6670\u5730\u8868\u793a\u4e8c\u5143\u72c0\u614b\uff0c\u6613\u65bc\u7406\u89e3\u548c\u7dad\u8b77\u3002<\/li>\n<\/ul>\n<h3 id=\"%e7%bc%ba%e9%bb%9e-DbFgQAPnIS\">\u7f3a\u9ede<\/h3>\n<ul>\n<li>\u6253\u5305\u6548\u61c9\uff1a\u7576\u6709\u591a\u500bBIT\u5217\u6642\uff0c\u53ef\u80fd\u6703\u5c0e\u81f4\u5b58\u5132\u7a7a\u9593\u7684\u6d6a\u8cbb\uff0c\u7279\u5225\u662f\u5728\u5217\u6578\u91cf\u4e0d\u591a\u7684\u60c5\u6cc1\u4e0b\u3002<\/li>\n<li>\u67e5\u8a62\u6027\u80fd\uff1a\u5728\u67d0\u4e9b\u60c5\u6cc1\u4e0b\uff0c\u4f7f\u7528BIT\u985e\u578b\u53ef\u80fd\u6703\u5f71\u97ff\u67e5\u8a62\u6027\u80fd\uff0c\u7279\u5225\u662f\u5728\u9700\u8981\u9032\u884c\u5927\u91cf\u8a08\u7b97\u6642\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-DbFgQAPnIS\">\u7e3d\u7d50<\/h2>\n<p>SQL Server\u4e2d\u7684BIT\u985e\u578b\u662f\u4e00\u500b\u9ad8\u6548\u7684\u8cc7\u6599\u985e\u578b\uff0c\u9069\u5408\u7528\u65bc\u5132\u5b58\u5e03\u6797\u503c\u3002\u96d6\u7136\u5176\u7406\u8ad6\u4e0a\u53ea\u97001\u4f4d\u5143\uff0c\u4f46\u5be6\u969b\u5b58\u5132\u7a7a\u9593\u6703\u6839\u64da\u5217\u7684\u6578\u91cf\u9032\u884c\u6253\u5305\u3002\u4e86\u89e3BIT\u985e\u578b\u7684\u5b58\u5132\u7279\u6027\u548c\u4f7f\u7528\u5834\u666f\uff0c\u53ef\u4ee5\u5e6b\u52a9\u958b\u767c\u8005\u5728\u8a2d\u8a08\u8cc7\u6599\u5eab\u6642\u505a\u51fa\u66f4\u660e\u667a\u7684\u9078\u64c7\u3002<\/p>\n<p>\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u9ad8\u6548\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0cServer.HK \u63d0\u4f9b\u591a\u7a2e\u9078\u64c7\uff0c\u6eff\u8db3\u60a8\u7684\u9700\u6c42\u3002\u7121\u8ad6\u662f <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u9084\u662f\u5176\u4ed6 <a href=\"https:\/\/server.hk\">\u4f3a\u670d\u5668<\/a> \u65b9\u6848\uff0c\u6211\u5011\u90fd\u80fd\u70ba\u60a8\u63d0\u4f9b\u7a69\u5b9a\u53ef\u9760\u7684\u670d\u52d9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SQL Server BIT\u985e\u578b\u4f54\u75281\u4f4d\u5143\uff0c\u6700\u591a\u53ef\u5132\u5b582\u500b\u72c0\u614b\uff080\u62161\uff09\uff0c\u6709\u6548\u5229\u7528\u7a7a\u9593\uff0c\u9069\u5408\u5132\u5b58\u5e03\u6797\u503c\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-137191","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/137191","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=137191"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/137191\/revisions"}],"predecessor-version":[{"id":137192,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/137191\/revisions\/137192"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=137191"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=137191"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=137191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}