{"id":476178,"date":"2023-08-09T07:26:52","date_gmt":"2023-08-09T07:26:52","guid":{"rendered":""},"modified":"2023-09-05T11:12:10","modified_gmt":"2023-09-05T11:12:10","slug":"cardinality-sql","status":"publish","type":"wiki","link":"https:\/\/oneproxy.pro\/cn\/wiki\/cardinality-sql\/","title":{"rendered":"\u57fa\u6570 (SQL)"},"content":{"rendered":"<p>SQL \u4e2d\u7684\u57fa\u6570\u662f\u6307\u6570\u636e\u5e93\u8868\u7684\u5217\u6216\u7d22\u5f15\u4e2d\u503c\u7684\u4e0d\u540c\u6570\u91cf\u3002\u5b83\u5728\u67e5\u8be2\u4f18\u5316\u548c\u6027\u80fd\u8c03\u4f18\u4e2d\u8d77\u7740\u81f3\u5173\u91cd\u8981\u7684\u4f5c\u7528\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u6d1e\u5bdf\u6570\u636e\u5206\u5e03\u5e76\u5e2e\u52a9\u6570\u636e\u5e93\u5f15\u64ce\u5728\u751f\u6210\u6267\u884c\u8ba1\u5212\u65f6\u505a\u51fa\u660e\u667a\u7684\u51b3\u7b56\u3002\u57fa\u6570\u662f\u6570\u636e\u5e93\u9886\u57df\u7684\u4e00\u4e2a\u57fa\u672c\u6982\u5ff5\uff0c\u5e7f\u6cdb\u5e94\u7528\u4e8e\u5404\u79cd\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf (DBMS)\u3002<\/p>\n<h2>\u57fa\u6570 (SQL) \u7684\u8d77\u6e90\u5386\u53f2\u4ee5\u53ca\u5bf9\u5b83\u7684\u9996\u6b21\u63d0\u53ca<\/h2>\n<p>SQL \u4e2d\u7684\u57fa\u6570\u6982\u5ff5\u53ef\u4ee5\u8ffd\u6eaf\u5230\u5173\u7cfb\u6570\u636e\u5e93\u7684\u65e9\u671f\u3002\u5173\u7cfb\u6a21\u578b\u662f\u7531 EF Codd \u535a\u58eb\u5728 1970 \u5e74\u53d1\u8868\u7684\u5f00\u521b\u6027\u8bba\u6587\u300a\u5927\u578b\u5171\u4eab\u6570\u636e\u5e93\u7684\u5173\u7cfb\u6570\u636e\u6a21\u578b\u300b\u4e2d\u63d0\u51fa\u7684\u3002\u5728\u8fd9\u7bc7\u8bba\u6587\u4e2d\uff0cCodd \u63d0\u51fa\u4e86\u5728\u5177\u6709\u884c\u548c\u5217\u7684\u8868\u4e2d\u8868\u793a\u6570\u636e\u7684\u60f3\u6cd5\uff0c\u4ee5\u53ca\u4e00\u7ec4\u7528\u4e8e\u64cd\u4f5c\u6570\u636e\u7684\u6570\u5b66\u8fd0\u7b97\u3002<\/p>\n<p>\u968f\u7740\u5173\u7cfb\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\u7684\u53d1\u5c55\u548c\u6210\u719f\uff0c\u201c\u57fa\u6570\u201d\u4e00\u8bcd\u540e\u6765\u9010\u6e10\u6d41\u884c\u8d77\u6765\u3002\u5b83\u56e0\u5176\u5728\u67e5\u8be2\u4f18\u5316\u4e2d\u7684\u91cd\u8981\u6027\u800c\u53d7\u5230\u91cd\u89c6\uff0c\u5728\u67e5\u8be2\u4f18\u5316\u4e2d\uff0c\u4f30\u8ba1\u67e5\u8be2\u5c06\u8fd4\u56de\u7684\u884c\u6570\u4ee5\u9009\u62e9\u6700\u6709\u6548\u7684\u6267\u884c\u8ba1\u5212\u53d8\u5f97\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<h2>\u6709\u5173\u57fa\u6570 (SQL) \u7684\u8be6\u7ec6\u4fe1\u606f<\/h2>\n<p>\u5728 SQL \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u4e2d\uff0c\u57fa\u6570\u662f\u6307\u5217\u6216\u7d22\u5f15\u4e2d\u5b58\u5728\u7684\u4e0d\u540c\u503c\u7684\u6570\u91cf\u3002\u5b83\u63d0\u4f9b\u6709\u5173\u8868\u4e2d\u6570\u636e\u5206\u5e03\u7684\u7edf\u8ba1\u4fe1\u606f\uff0c\u5e2e\u52a9\u67e5\u8be2\u4f18\u5316\u5668\u786e\u5b9a\u5904\u7406\u67e5\u8be2\u7684\u6700\u6709\u6548\u65b9\u6cd5\u3002<\/p>\n<h2>\u57fa\u6570 (SQL) \u7684\u5185\u90e8\u7ed3\u6784\u53ca\u5176\u5de5\u4f5c\u539f\u7406<\/h2>\n<p>\u57fa\u6570\u7684\u5185\u90e8\u7ed3\u6784\u5728\u6570\u636e\u5e93\u7edf\u8ba1\u4fe1\u606f\u4e2d\u7ef4\u62a4\u3002DBMS \u5b58\u50a8\u6709\u5173\u8868\u548c\u7d22\u5f15\u7684\u7edf\u8ba1\u4fe1\u606f\uff0c\u5176\u4e2d\u5305\u62ec\u6709\u5173\u884c\u6570\u3001\u4e0d\u540c\u503c\u548c\u6570\u636e\u5206\u5e03\u7684\u4fe1\u606f\u3002\u6267\u884c\u67e5\u8be2\u65f6\uff0c\u67e5\u8be2\u4f18\u5316\u5668\u4f7f\u7528\u8fd9\u4e9b\u7edf\u8ba1\u4fe1\u606f\u6765\u4f30\u8ba1\u57fa\u6570\u5e76\u9009\u62e9\u6700\u4f73\u67e5\u8be2\u6267\u884c\u8ba1\u5212\u3002<\/p>\n<p>\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\u53ef\u4ee5\u4f7f\u7528\u5404\u79cd\u7b97\u6cd5\u548c\u6570\u636e\u7ed3\u6784\u6765\u6709\u6548\u5730\u8ddf\u8e2a\u57fa\u6570\u3002\u5f53\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\u53d1\u751f\u53d8\u5316\u65f6\uff0c\u8fd9\u4e9b\u7ed3\u6784\u4f1a\u5b9a\u671f\u6216\u6309\u9700\u66f4\u65b0\u3002<\/p>\n<h2>\u57fa\u6570\uff08SQL\uff09\u4e3b\u8981\u7279\u6027\u5206\u6790<\/h2>\n<p>SQL \u4e2d\u57fa\u6570\u7684\u4e3b\u8981\u7279\u6027\u5305\u62ec\uff1a<\/p>\n<ol>\n<li>\n<p><strong>\u67e5\u8be2\u4f18\u5316\uff1a<\/strong> \u57fa\u6570\u662f\u786e\u5b9a\u67e5\u8be2\u6267\u884c\u8ba1\u5212\u7684\u5173\u952e\u56e0\u7d20\u3002\u57fa\u6570\u8d8a\u9ad8\uff0c\u7d22\u5f15\u7684\u9009\u62e9\u6027\u5c31\u8d8a\u5f3a\uff0c\u67e5\u8be2\u6267\u884c\u901f\u5ea6\u5c31\u8d8a\u5feb\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u6570\u636e\u5206\u5e03\u5206\u6790\uff1a<\/strong> \u57fa\u6570\u53ef\u4ee5\u6d1e\u6089\u5217\u4e2d\u6570\u636e\u503c\u7684\u5206\u5e03\u60c5\u51b5\u3002\u5b83\u6709\u52a9\u4e8e\u8bc6\u522b\u6f5c\u5728\u7684\u6570\u636e\u8d28\u91cf\u95ee\u9898\uff0c\u4f8b\u5982\u6570\u636e\u504f\u5dee\u6216\u91cd\u590d\u6761\u76ee\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u8fde\u63a5\u4f18\u5316\uff1a<\/strong> \u57fa\u6570\u5728\u4f18\u5316\u8fde\u63a5\u64cd\u4f5c\u4e2d\u8d77\u7740\u91cd\u8981\u4f5c\u7528\u3002\u6570\u636e\u5e93\u4f18\u5316\u5668\u4f7f\u7528\u8fde\u63a5\u5217\u7684\u57fa\u6570\u6765\u9009\u62e9\u6700\u6709\u6548\u7684\u8fde\u63a5\u7b56\u7565\uff0c\u4f8b\u5982\u5d4c\u5957\u5faa\u73af\u8fde\u63a5\u3001\u54c8\u5e0c\u8fde\u63a5\u6216\u5408\u5e76\u8fde\u63a5\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u7d22\u5f15\u8bbe\u8ba1\uff1a<\/strong> \u57fa\u6570\u4f1a\u5f71\u54cd\u6570\u636e\u5e93\u7d22\u5f15\u7684\u6709\u6548\u6027\u3002\u4f4e\u57fa\u6570\u5217\u4e0d\u9002\u5408\u7d22\u5f15\uff0c\u56e0\u4e3a\u5b83\u4eec\u6ca1\u6709\u63d0\u4f9b\u592a\u591a\u7684\u9009\u62e9\u6027\uff0c\u800c\u9ad8\u57fa\u6570\u5217\u66f4\u9002\u5408\u7d22\u5f15\u3002<\/p>\n<\/li>\n<\/ol>\n<h2>\u57fa\u6570\u7c7b\u578b (SQL)<\/h2>\n<p>\u57fa\u6570\u4e3b\u8981\u6709\u4e09\u79cd\u7c7b\u578b\uff1a<\/p>\n<ol>\n<li>\n<p><strong>\u4f4e\u57fa\u6570\uff1a<\/strong> \u57fa\u6570\u8f83\u4f4e\u7684\u5217\u76f8\u5bf9\u4e8e\u8868\u4e2d\u7684\u603b\u884c\u6570\u5177\u6709\u8f83\u5c11\u7684\u4e0d\u540c\u503c\u3002\u5e38\u89c1\u793a\u4f8b\u5305\u62ec\u6027\u522b\u6216\u56fd\u5bb6\/\u5730\u533a\u5217\uff0c\u8fd9\u4e9b\u5217\u901a\u5e38\u53ea\u6709\u5c11\u6570\u552f\u4e00\u503c\u5728\u591a\u884c\u4e2d\u91cd\u590d\u51fa\u73b0\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u9ad8\u57fa\u6570\uff1a<\/strong> \u5177\u6709\u9ad8\u57fa\u6570\u7684\u5217\u76f8\u5bf9\u4e8e\u8868\u4e2d\u7684\u603b\u884c\u6570\u5177\u6709\u5927\u91cf\u4e0d\u540c\u7684\u503c\u3002\u4f8b\u5982\uff0c\u4e3b\u952e\u6216\u552f\u4e00\u6807\u8bc6\u7b26\u5217\u5f80\u5f80\u5177\u6709\u9ad8\u57fa\u6570\uff0c\u56e0\u4e3a\u6bcf\u884c\u90fd\u6709\u4e00\u4e2a\u552f\u4e00\u503c\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u4e2d\u7b49\u57fa\u6570\uff1a<\/strong> \u4e2d\u7b49\u57fa\u6570\u4ecb\u4e8e\u4f4e\u57fa\u6570\u548c\u9ad8\u57fa\u6570\u4e4b\u95f4\u3002\u4e2d\u7b49\u57fa\u6570\u7684\u5217\u5177\u6709\u9002\u91cf\u7684\u4e0d\u540c\u503c\uff0c\u56e0\u6b64\u5b83\u4eec\u7684\u9009\u62e9\u6027\u6bd4\u4f4e\u57fa\u6570\u5217\u66f4\u9ad8\uff0c\u4f46\u6bd4\u9ad8\u57fa\u6570\u5217\u66f4\u4f4e\u3002<\/p>\n<\/li>\n<\/ol>\n<p>\u4ee5\u4e0b\u662f\u4e09\u79cd\u57fa\u6570\u7c7b\u578b\u7684\u6bd4\u8f83\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u57fa\u6570\u7c7b\u578b<\/th>\n<th>\u4e0d\u540c\u503c\u7684\u6570\u91cf<\/th>\n<th>\u9009\u62e9\u6027<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u4f4e\u7684<\/td>\n<td>\u5f88\u5c11<\/td>\n<td>\u4f4e\u7684<\/td>\n<\/tr>\n<tr>\n<td>\u4e2d\u7b49\u7684<\/td>\n<td>\u7f13\u548c<\/td>\n<td>\u4e2d\u7b49\u7684<\/td>\n<\/tr>\n<tr>\n<td>\u9ad8\u7684<\/td>\n<td>\u8bb8\u591a<\/td>\n<td>\u9ad8\u7684<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u4f7f\u7528 Cardinality (SQL) \u7684\u65b9\u6cd5\u3001\u95ee\u9898\u53ca\u5176\u89e3\u51b3\u65b9\u6cd5<\/h2>\n<h3>\u5728 SQL \u4e2d\u4f7f\u7528\u57fa\u6570\u7684\u65b9\u6cd5<\/h3>\n<ol>\n<li>\n<p><strong>\u67e5\u8be2\u6027\u80fd\u4f18\u5316\uff1a<\/strong> \u57fa\u6570\u53ef\u5e2e\u52a9\u67e5\u8be2\u4f18\u5316\u5668\u9009\u62e9\u6700\u6709\u6548\u7684\u6267\u884c\u8ba1\u5212\uff0c\u4ece\u800c\u63d0\u9ad8\u67e5\u8be2\u6027\u80fd\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u6307\u6570\u9009\u62e9\uff1a<\/strong> \u901a\u8fc7\u5206\u6790\u57fa\u6570\uff0c\u60a8\u53ef\u4ee5\u505a\u51fa\u660e\u667a\u7684\u51b3\u5b9a\uff0c\u9009\u62e9\u5bf9\u54ea\u4e9b\u5217\u8fdb\u884c\u7d22\u5f15\u4ee5\u83b7\u5f97\u66f4\u597d\u7684\u67e5\u8be2\u6027\u80fd\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u6570\u636e\u8d28\u91cf\u5206\u6790\uff1a<\/strong> \u57fa\u6570\u6709\u52a9\u4e8e\u8bc6\u522b\u91cd\u590d\u6216\u4e22\u5931\u7684\u6570\u636e\uff0c\u8fd9\u5bf9\u4e8e\u6570\u636e\u6e05\u7406\u548c\u7ef4\u62a4\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<\/li>\n<\/ol>\n<h3>SQL \u4e2d\u4e0e\u57fa\u6570\u76f8\u5173\u7684\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6848<\/h3>\n<ol>\n<li>\n<p><strong>\u8fc7\u65f6\u7684\u7edf\u8ba1\u6570\u636e\uff1a<\/strong> \u8fc7\u65f6\u6216\u4e0d\u51c6\u786e\u7684\u7edf\u8ba1\u6570\u636e\u53ef\u80fd\u4f1a\u5bfc\u81f4\u67e5\u8be2\u8ba1\u5212\u4e0d\u7406\u60f3\u3002\u5b9a\u671f\u66f4\u65b0\u6570\u636e\u5e93\u7edf\u8ba1\u6570\u636e\u4ee5\u786e\u4fdd\u51c6\u786e\u7684\u57fa\u6570\u4f30\u8ba1\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u6570\u636e\u5206\u5e03\u503e\u659c\uff1a<\/strong> \u6570\u636e\u5206\u5e03\u4e0d\u5747\uff08\u5373\u67d0\u4e2a\u503c\u5360\u636e\u67d0\u4e00\u5217\u7684\u4e3b\u5bfc\u5730\u4f4d\uff09\u53ef\u80fd\u4f1a\u5bfc\u81f4\u67e5\u8be2\u8ba1\u5212\u6548\u7387\u4f4e\u4e0b\u3002\u8bf7\u8003\u8651\u4f7f\u7528\u5206\u533a\u6216\u7d22\u5f15\u6765\u5904\u7406\u6b64\u7c7b\u60c5\u51b5\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u76f4\u65b9\u56fe\u7bb1\u5927\u5c0f\uff1a<\/strong> \u7528\u4e8e\u57fa\u6570\u4f30\u8ba1\u7684\u76f4\u65b9\u56fe\u53ef\u80fd\u5177\u6709\u4e0d\u540c\u7684\u7bb1\u4f53\u5927\u5c0f\uff0c\u4ece\u800c\u5bfc\u81f4\u57fa\u6570\u4f30\u8ba1\u4e0d\u51c6\u786e\u3002\u8c03\u6574\u76f4\u65b9\u56fe\u7bb1\u4f53\u5927\u5c0f\u53ef\u4ee5\u63d0\u9ad8\u51c6\u786e\u6027\u3002<\/p>\n<\/li>\n<\/ol>\n<h2>\u4e3b\u8981\u7279\u70b9\u53ca\u4e0e\u540c\u7c7b\u672f\u8bed\u7684\u5176\u4ed6\u6bd4\u8f83<\/h2>\n<h3>\u57fa\u6570\u4e0e\u5bc6\u5ea6<\/h3>\n<p>\u57fa\u6570\u548c\u5bc6\u5ea6\u662f\u67e5\u8be2\u4f18\u5316\u4e2d\u4f7f\u7528\u7684\u4e24\u4e2a\u57fa\u672c\u6982\u5ff5\uff0c\u4f46\u5b83\u4eec\u6709\u4e0d\u540c\u7684\u7528\u9014\uff1a<\/p>\n<ul>\n<li>\n<p><strong>\u57fa\u6570<\/strong> \u6307\u5217\u6216\u7d22\u5f15\u4e2d\u4e0d\u540c\u503c\u7684\u6570\u91cf\uff0c\u5e2e\u52a9\u67e5\u8be2\u4f18\u5316\u5668\u4f30\u8ba1\u67e5\u8be2\u8fd4\u56de\u7684\u884c\u6570\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u5bc6\u5ea6<\/strong> \u8868\u793a\u7d22\u5f15\u4e2d\u6570\u636e\u503c\u7684\u552f\u4e00\u6027\u3002\u5b83\u662f\u57fa\u6570\u7684\u5012\u6570\uff0c\u8868\u793a\u4e24\u4e2a\u968f\u673a\u9009\u62e9\u7684\u884c\u5bf9\u4e8e\u7d22\u5f15\u5217\u5177\u6709\u76f8\u540c\u503c\u7684\u53ef\u80fd\u6027\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u867d\u7136\u57fa\u6570\u548c\u5bc6\u5ea6\u90fd\u4f1a\u5f71\u54cd\u67e5\u8be2\u4f18\u5316\uff0c\u4f46\u5b83\u4eec\u4e3a\u67e5\u8be2\u4f18\u5316\u5668\u63d0\u4f9b\u4e86\u4e0d\u540c\u7684\u4fe1\u606f\uff0c\u4ee5\u4fbf\u6709\u6548\u5730\u9009\u62e9\u67e5\u8be2\u8ba1\u5212\u3002<\/p>\n<h2>\u4e0e\u57fa\u6570 (SQL) \u76f8\u5173\u7684\u672a\u6765\u89c2\u70b9\u548c\u6280\u672f<\/h2>\n<p>\u968f\u7740\u6280\u672f\u8fdb\u6b65\u548c\u6570\u636e\u5e93\u53d8\u5f97\u8d8a\u6765\u8d8a\u590d\u6742\uff0cSQL \u4e2d\u57fa\u6570\u7684\u91cd\u8981\u6027\u5c06\u4e0d\u65ad\u589e\u957f\u3002\u67e5\u8be2\u4f18\u5316\u7b97\u6cd5\u548c\u9ad8\u7ea7\u7edf\u8ba1\u6280\u672f\u7684\u672a\u6765\u53d1\u5c55\u6709\u671b\u8fdb\u4e00\u6b65\u63d0\u9ad8\u57fa\u6570\u4f30\u8ba1\u7684\u51c6\u786e\u6027\u3002\u6b64\u5916\uff0c\u786c\u4ef6\u548c\u6570\u636e\u5e93\u67b6\u6784\u7684\u8fdb\u6b65\u5c06\u5e26\u6765\u66f4\u9ad8\u6548\u7684\u57fa\u6570\u8ba1\u7b97\uff0c\u4ece\u800c\u63d0\u9ad8\u6570\u636e\u5e93\u7cfb\u7edf\u7684\u6574\u4f53\u6027\u80fd\u3002<\/p>\n<h2>\u5982\u4f55\u4f7f\u7528\u4ee3\u7406\u670d\u52a1\u5668\u6216\u5c06\u5176\u4e0e Cardinality (SQL) \u5173\u8054<\/h2>\n<p>\u4ee3\u7406\u670d\u52a1\u5668\uff08\u4f8b\u5982 OneProxy \u63d0\u4f9b\u7684\u4ee3\u7406\u670d\u52a1\u5668\uff09\u5728\u8bbf\u95ee Web \u8d44\u6e90\u65f6\uff0c\u5728\u589e\u5f3a\u9690\u79c1\u3001\u5b89\u5168\u6027\u548c\u6027\u80fd\u65b9\u9762\u53d1\u6325\u7740\u81f3\u5173\u91cd\u8981\u7684\u4f5c\u7528\u3002\u867d\u7136\u4ee3\u7406\u670d\u52a1\u5668\u4e0e SQL \u4e2d\u7684\u57fa\u6570\u6ca1\u6709\u76f4\u63a5\u5173\u7cfb\uff0c\u4f46\u53ef\u4ee5\u4e0e\u6570\u636e\u5e93\u5e94\u7528\u7a0b\u5e8f\u7ed3\u5408\u4f7f\u7528\uff0c\u4ee5\u6539\u5584\u6570\u636e\u8bbf\u95ee\u548c\u53ef\u7528\u6027\u3002<\/p>\n<p>\u4ee3\u7406\u670d\u52a1\u5668\u53ef\u4ee5\u7f13\u5b58\u7ecf\u5e38\u8bbf\u95ee\u7684\u6570\u636e\u5e93\u8d44\u6e90\uff0c\u4ece\u800c\u51cf\u5c11\u5230\u8fbe\u6570\u636e\u5e93\u670d\u52a1\u5668\u7684\u8bf7\u6c42\u6570\u91cf\uff0c\u5e76\u53ef\u80fd\u7f29\u77ed\u54cd\u5e94\u65f6\u95f4\u3002\u6b64\u5916\uff0c\u4ee3\u7406\u670d\u52a1\u5668\u53ef\u4ee5\u5145\u5f53\u5ba2\u6237\u7aef\u548c\u6570\u636e\u5e93\u4e4b\u95f4\u7684\u4e2d\u4ecb\uff0c\u589e\u52a0\u989d\u5916\u7684\u5b89\u5168\u6027\u548c\u8d1f\u8f7d\u5e73\u8861\u5c42\uff0c\u8fd9\u5728\u9ad8\u6d41\u91cf\u60c5\u51b5\u4e0b\u5c24\u5176\u6709\u7528\u3002<\/p>\n<h2>\u76f8\u5173\u94fe\u63a5<\/h2>\n<p>\u6709\u5173 SQL \u4e2d\u57fa\u6570\u7684\u66f4\u591a\u4fe1\u606f\uff0c\u60a8\u53ef\u80fd\u4f1a\u53d1\u73b0\u4ee5\u4e0b\u8d44\u6e90\u5f88\u6709\u5e2e\u52a9\uff1a<\/p>\n<ul>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/previous-versions\/sql\/sql-server-2008\/dd535534(v=sql.100)\" target=\"_new\" rel=\"noopener nofollow\">\u4e86\u89e3 SQL Server \u57fa\u6570\u4f30\u8ba1<\/a><\/li>\n<li><a href=\"https:\/\/www.postgresql.org\/docs\/current\/planner-stats.html\" target=\"_new\" rel=\"noopener nofollow\">PostgreSQL \u4e2d\u7684\u57fa\u6570\u4f30\u8ba1<\/a><\/li>\n<li><a href=\"https:\/\/dev.mysql.com\/doc\/mysql\/en\/query-optimization.html\" target=\"_new\" rel=\"noopener nofollow\">MySQL \u67e5\u8be2\u4f18\u5316\u548c\u57fa\u6570<\/a><\/li>\n<\/ul>\n<p>\u8bf7\u8bb0\u4f4f\uff0c\u4e86\u89e3\u57fa\u6570\u5bf9\u4e8e\u4f18\u5316\u6570\u636e\u5e93\u6027\u80fd\u548c\u786e\u4fdd\u9ad8\u6548\u6267\u884c\u67e5\u8be2\u81f3\u5173\u91cd\u8981\u3002 \u7d27\u8ddf\u6570\u636e\u5e93\u6280\u672f\u7684\u6700\u65b0\u53d1\u5c55\u5c06\u8fdb\u4e00\u6b65\u5e2e\u52a9\u60a8\u505a\u51fa\u660e\u667a\u7684\u51b3\u7b56\u5e76\u5145\u5206\u53d1\u6325\u6570\u636e\u9a71\u52a8\u5e94\u7528\u7a0b\u5e8f\u7684\u6f5c\u529b\u3002<\/p>","protected":false},"featured_media":467828,"menu_order":0,"template":"","meta":{"_acf_changed":false,"content-type":"","inline_featured_image":false,"footnotes":""},"class_list":["post-476178","wiki","type-wiki","status-publish","has-post-thumbnail","hentry"],"acf":{"faq_title":"Frequently Asked Questions about <mark>Cardinality (SQL)<\/mark>","faq_items":[{"question":"What is Cardinality in SQL?","answer":"<p>Cardinality in SQL refers to the number of distinct values present in a column or index of a database table. It helps the database engine optimize queries and make efficient execution plans.<\/p>"},{"question":"How does Cardinality work in SQL?","answer":"<p>Cardinality is maintained within the database statistics, which store information about the number of rows, distinct values, and data distribution. The query optimizer uses this information to estimate the number of rows returned by a query and choose the best execution plan.<\/p>"},{"question":"What are the types of Cardinality in SQL?","answer":"<p>There are three primary types of Cardinality:<\/p><ol><li>Low Cardinality: Few distinct values, often seen in columns like gender or country.<\/li><li>Medium Cardinality: Moderate distinct values, falling between low and high Cardinality.<\/li><li>High Cardinality: Many distinct values, common in primary key or unique identifier columns.<\/li><\/ol>"},{"question":"How can I use Cardinality in SQL?","answer":"<p>Cardinality is essential for:<\/p><ul><li>Optimizing query performance<\/li><li>Selecting appropriate indexes for better performance<\/li><li>Identifying data quality issues like duplicates or missing data<\/li><\/ul>"},{"question":"What are the challenges related to Cardinality in SQL?","answer":"<p>Problems related to Cardinality include outdated statistics, skewed data distribution, and inaccurate histogram bin sizes. Regularly updating statistics and considering partitioning or indexing can address these challenges.<\/p>"},{"question":"How is Cardinality different from Density in SQL?","answer":"<p>Cardinality represents the number of distinct values, while Density indicates the uniqueness of data values in an index. Both impact query optimization but serve different purposes.<\/p>"},{"question":"What is the future perspective of Cardinality in SQL?","answer":"<p>As technology advances, Cardinality's importance will continue to grow, leading to more accurate estimations and efficient query plans. Advancements in hardware and database architecture will further improve Cardinality computations and overall database performance.<\/p>"},{"question":"How can proxy servers be associated with Cardinality in SQL?","answer":"<p>While not directly related, proxy servers can work with database applications to improve data access and availability. They can cache frequently accessed resources, add security layers, and perform load balancing for high-traffic scenarios.<\/p>"}]},"_links":{"self":[{"href":"https:\/\/oneproxy.pro\/cn\/wp-json\/wp\/v2\/wiki\/476178","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oneproxy.pro\/cn\/wp-json\/wp\/v2\/wiki"}],"about":[{"href":"https:\/\/oneproxy.pro\/cn\/wp-json\/wp\/v2\/types\/wiki"}],"version-history":[{"count":0,"href":"https:\/\/oneproxy.pro\/cn\/wp-json\/wp\/v2\/wiki\/476178\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/oneproxy.pro\/cn\/wp-json\/wp\/v2\/media\/467828"}],"wp:attachment":[{"href":"https:\/\/oneproxy.pro\/cn\/wp-json\/wp\/v2\/media?parent=476178"}],"curies":[{"name":"\u53ef\u6e7f\u6027\u7c89\u5242","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}