{"id":234,"date":"2025-11-20T18:40:57","date_gmt":"2025-11-20T10:40:57","guid":{"rendered":"https:\/\/www.syh.ac.cn\/?p=234"},"modified":"2025-11-20T18:40:57","modified_gmt":"2025-11-20T10:40:57","slug":"%e8%bd%ac%e8%bd%bd%e4%ba%ba%e5%a4%a7%e9%87%91%e4%bb%93%e6%95%b0%e6%8d%ae%e5%ba%93kdb%e4%b8%8emysql%e4%b8%8d%e5%85%bc%e5%ae%b9%e8%ae%b0%e5%bd%95%e5%8f%8a%e4%bd%bf%e7%94%a8%e5%bf%83%e5%be%97%e6%95%b4","status":"publish","type":"post","link":"http:\/\/www.syh.ac.cn\/index.php\/2025\/11\/20\/%e8%bd%ac%e8%bd%bd%e4%ba%ba%e5%a4%a7%e9%87%91%e4%bb%93%e6%95%b0%e6%8d%ae%e5%ba%93kdb%e4%b8%8emysql%e4%b8%8d%e5%85%bc%e5%ae%b9%e8%ae%b0%e5%bd%95%e5%8f%8a%e4%bd%bf%e7%94%a8%e5%bf%83%e5%be%97%e6%95%b4\/","title":{"rendered":"(\u8f6c\u8f7d)\u4eba\u5927\u91d1\u4ed3\u6570\u636e\u5e93KDB\u4e0eMySQL\u4e0d\u517c\u5bb9\u8bb0\u5f55\u53ca\u4f7f\u7528\u5fc3\u5f97\u6574\u7406"},"content":{"rendered":"\n<p>\u56e0\u624b\u4e0a\u7684\u67d0\u9879\u76ee\u9700\u8981\u8fc1\u81f3\u653f\u52a1\u4e91\uff0c\u5168\u9762\u91c7\u7528\u56fd\u4ea7\u5316\u8f6f\u4ef6\u3002\u8fd9\u91cc\u8bb0\u5f55\u4e00\u4e0b\u5c06Mysql\u8fc1\u81f3\u4eba\u5927\u91d1\u4ed3\u6570\u636e\u5e93V8R6\uff08\u662f\u6307V008R006C009B0014\u7248\u672c\uff0c\u4e0d\u540c\u7248\u672c\u533a\u522b\u8f83\u5927\uff09\u7248\u672c\u7684\u4e00\u4e9b\u4e0d\u517c\u5bb9\u53ca\u5176\u5b83\u8bb0\u5f55\u3002\u4ee5\u4e0b\u5185\u5bb9\u6709\u90e8\u5206\u662f\u6765\u6e90\u4e8e\u7f51\u7edc\u6536\u96c6\uff0c\u5e76\u672a\u7ecf\u8fc7\u672c\u4eba\u9a8c\u8bc1\uff1b\u90e8\u5206\u4e3a\u672c\u4eba\u4f7f\u7528\u9047\u5230\u7684\uff0c\u662f\u5426\u901a\u7528\u672a\u77e5\u3002<\/p>\n\n\n\n<p> <strong>\u200c\u4e00\u3001\u51fd\u6570\u5dee\u5f02\u200c\uff1a<\/strong> <\/p>\n\n\n\n<p>MySQL\u4e2d\u7684sysdate()\u51fd\u6570\u5728\u91d1\u4ed3\u6570\u636e\u5e93\u4e2d\u4e0d\u5b58\u5728\uff0c\u53ef\u4ee5\u4f7f\u7528current_timestamp()\u66ff\u6362\u200c\u3002 <\/p>\n\n\n\n<p>MySQL\u4e2d\u7684STR_TO_DATE\u51fd\u6570\u5728\u91d1\u4ed3\u6570\u636e\u5e93\u4e2d\u4e0d\u5b58\u5728\uff0c\u53ef\u4ee5\u4f7f\u7528to_date(n, format)\u66ff\u6362\u200c\u3002<\/p>\n\n\n\n<p> MySQL\u4e2d\u7684UUID()\u51fd\u6570\u5728\u91d1\u4ed3\u6570\u636e\u5e93\u4e2d\u53ef\u4ee5\u901a\u8fc7SYS_GUID()\u66ff\u6362\u200c\u3002 <\/p>\n\n\n\n<p>\u65e5\u671f\u8ba1\u7b97\u65b9\u9762\uff0cMySQL\u4e2d\u7684now() + interval -1 day\u9700\u8981\u6539\u4e3a\u91d1\u4ed3\u6570\u636e\u5e93\u7684now() &#8211; interval &#8216;1&#8217; day \u6216 DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL &#8216;1&#8217; DAY)\u200c\u3002<\/p>\n\n\n\n<p><strong>\u4e8c\u3001SQL\u8bed\u6cd5\u5dee\u5f02\u200c\uff1a<\/strong> <\/p>\n\n\n\n<p>MySQL\u4e2d\u67e5\u8be2\u4f7f\u7528\u53cc\u5f15\u53f7\u5728\u91d1\u4ed3\u6570\u636e\u5e93\u4e2d\u4e0d\u652f\u6301\uff0c\u9700\u6539\u4e3a\u5355\u5f15\u53f7\u200c\u3002<\/p>\n\n\n\n<p> MySQL\u4e2d\u7684GROUP BY\u8bed\u53e5\u5728\u8fd4\u56de\u5176\u4ed6\u975e\u805a\u5408\u5b57\u6bb5\u65f6\uff0c\u4e0d\u9700\u8981\u5bf9\u8fd9\u4e9b\u5b57\u6bb5\u4f7f\u7528\u51fd\u6570\u62ec\u8d77\u6765\uff0c\u4f46\u5728\u91d1\u4ed3\u6570\u636e\u5e93\u4e2d\u9700\u8981\uff0c\u5426\u5219\u53ef\u80fd\u62a5\u9519\u3002\u8fd9\u4e2a\u95ee\u9898\u53ef\u4ee5\u901a\u8fc7\u914d\u7f6e\u91d1\u4ed3\u6570\u636e\u5e93\u89e3\u51b3\u200c\u3002 <\/p>\n\n\n\n<p>MySQL\u4e2d\u7684INNER JOIN\u5728\u91d1\u4ed3\u6570\u636e\u5e93\u4e2d\u53ef\u80fd\u9700\u8981\u6539\u4e3a\u4f7f\u7528\u9017\u53f7\u5173\u8054\uff08\u4f46\u5de6\u8fde\u63a5\u548c\u53f3\u8fde\u63a5\u901a\u5e38\u6ca1\u95ee\u9898\uff09\u200c\u3002 <\/p>\n\n\n\n<p>MySQL\u4e2d\u7684\u67d0\u4e9b\u9690\u5f0f\u7c7b\u578b\u8f6c\u6362\u5728\u91d1\u4ed3\u6570\u636e\u5e93\u4e2d\u53ef\u80fd\u4e0d\u652f\u6301\uff0c\u9700\u8981\u624b\u52a8\u4f7f\u7528CAST()\u51fd\u6570\u8fdb\u884c\u8f6c\u6362\u200c\u3002<\/p>\n\n\n\n<p><strong>\u4e09\u3001\u7279\u5b9a\u529f\u80fd\u6216\u914d\u7f6e\u200c\uff1a<\/strong> <\/p>\n\n\n\n<p>MySQL\u4e2d\u7684\u67d0\u4e9bSQL\u6a21\u5f0f\uff08\u5982ONLY_FULL_GROUP_BY\uff09\u5728\u91d1\u4ed3\u6570\u636e\u5e93\u4e2d\u53ef\u80fd\u4e0d\u652f\u6301\u6216\u9700\u8981\u4e0d\u540c\u7684\u914d\u7f6e\u65b9\u5f0f\u200c\u3002 <\/p>\n\n\n\n<p>\u91d1\u4ed3\u6570\u636e\u5e93\u5ba2\u6237\u7aef\u7684\u5b89\u88c5\u5730\u5740\u4e0d\u80fd\u5305\u542b\u7a7a\u683c\uff0c\u5426\u5219\u53ef\u80fd\u5bfc\u81f4\u90e8\u5206\u6307\u4ee4\u6267\u884c\u62a5\u9519\u200c\u3002 <\/p>\n\n\n\n<p>\u67d0\u4e9b\u7b2c\u4e09\u65b9\u5de5\u5177\u6216\u6846\u67b6\uff08\u5982Activiti\u5de5\u4f5c\u6d415.22\u7248\u672c\uff09\u53ef\u80fd\u4e0d\u652f\u6301\u91d1\u4ed3\u6570\u636e\u5e93\u200c\u3002 <\/p>\n\n\n\n<p>\u91d1\u4ed3\u6570\u636e\u5e93\u5728\u517c\u5bb9MySQL\u65f6\uff0c\u53ef\u80fd\u8fd8\u5b58\u5728\u5176\u4ed6\u7ec6\u5fae\u7684\u5dee\u522b\uff0c\u5982\u5b57\u7b26\u4e32\u5305\u88f9\u65b9\u5f0f\u3001\u6b63\u5219\u8868\u8fbe\u5f0f\u7b49\u65b9\u9762\u7684\u5dee\u5f02\u200c\u3002<\/p>\n\n\n\n<p><strong>\u56db\u3001\u6570\u636e\u7c7b\u578b\u548c\u683c\u5f0f\u200c\uff1a<\/strong> <\/p>\n\n\n\n<p>MySQL\u4e2d\u7684\u65e5\u671f\u683c\u5f0f\u51fd\u6570\uff08\u5982DATE_FORMAT\uff09\u5728\u91d1\u4ed3\u6570\u636e\u5e93\u4e2d\u53ef\u80fd\u9700\u8981\u4f7f\u7528\u4e0d\u540c\u7684\u51fd\u6570\uff08\u5982TO_CHAR\uff09\u8fdb\u884c\u66ff\u6362\u200c\u3002<\/p>\n\n\n\n<p> MySQL\u4e2d\u7684IFNULL\u51fd\u6570\u5728\u91d1\u4ed3\u6570\u636e\u5e93\u4e2d\u53ef\u4ee5\u901a\u8fc7NVL\u51fd\u6570\u66ff\u6362\u200c\u3002<\/p>\n\n\n\n<p> MySQL\u4e2d\u7684SERIAL\u81ea\u589e\u4e3b\u952e\u53ef\u80fd\u4e0e\u91d1\u4ed3\u6570\u636e\u5e93\u4e2d\u7684\u539f\u6709\u6570\u636e\u5b58\u5728\u51b2\u7a81\u200c\u3002<\/p>\n\n\n\n<p><strong>\u4e94\u3001\u5176\u4ed6\u200c<\/strong>\uff1a<\/p>\n\n\n\n<p> 1\u3001group by\u5b57\u6bb5\u68c0\u6d4b\u6a21\u5f0f\uff1ashow sql_mode; \/\/\u67e5\u770b\u914d\u7f6e <\/p>\n\n\n\n<p>alter SYSTEM SET sql_mode = &#8216;ANSI_QUOTES&#8217;; \/\/\u53bb\u6389ONLY_FULL_GROUP_BY\uff0calter SYSTEM \u4fee\u6539\u5168\u5c40\u914d\u7f6e <\/p>\n\n\n\n<p>SELECT sys_reload_conf(); \u66f4\u65b0\u914d\u7f6e\u751f\u6548 <\/p>\n\n\n\n<p>2\u3001\u5b57\u6bb5\u7c7b\u578b\u9690\u5f0f\u8f6c\u6362 \u4eba\u5927\u91d1\u4ed3\u4e0d\u4f1a\u81ea\u52a8\u8f6c\u6362\u7c7b\u578b\uff0c\u9700\u8981cast()\u624b\u52a8\u8f6c\u6362 \u5426\u5219\u62a5invalid input syntax for type XX <\/p>\n\n\n\n<p>3\u3001join\u540e\u5fc5\u987b\u5e26on select * from a left join b on 1 =1 <\/p>\n\n\n\n<p>4\u3001\uff08\uff09\u4e2d\u6587\u62ec\u53f7\u4f1a\u5f71\u54cd\u8bed\u6cd5\u5224\u65ad\u62a5 syntax error at or near &#8230;.<\/p>\n\n\n\n<p>5\u3001activiti\u5de5\u4f5c\u6d415.22\u7248\u672c\u4e0d\u652f\u6301\u4eba\u5927\u91d1\u4ed3\u6570\u636e\u5e93couldn&#8217;t deduct database type from database product name &#8216;KingbaseES&#8217; \u53c2\u8003<a href=\"https:\/\/www.cnblogs.com\/montaro\/p\/17956719\">https:\/\/www.cnblogs.com\/montaro\/p\/17956719<\/a> \u4e0d\u66f4\u6539\u7248\u672c\u548c\u6e90\u7801\u9002\u914d\u4eba\u5927\u91d1\u4ed3 <\/p>\n\n\n\n<p>6\u3001\u4e0emysql\u51fd\u6570\u51b2\u7a81 mysql\uff1a DATE_SUB(CURDATE(), INTERVAL 1 MONTH) \u4eba\u5927\u91d1\u4ed3\uff1aDATE_SUB(CURDATE(), INTERVAL &#8216;1&#8217; MONTH) <\/p>\n\n\n\n<p>7\u3001\u4eba\u5927\u91d1\u4ed3\u5ba2\u6237\u7aef\u5b89\u88c5\u5730\u5740\u4e0d\u80fd\u6709\u7a7a\u683c\uff0c\u6bd4\u5982c:\/program file\uff0c\u5426\u5219\u90e8\u5206\u6307\u4ee4\u6267\u884c\u62a5\u9519 <\/p>\n\n\n\n<p>8\u3001mybats\u548c\u4eba\u5927\u91d1\u4ed3\u5173\u952e\u5b57level\u51b2\u7a81\uff0c\u62a5CONNECT BY clause required in this query block\uff0c \u4f7f\u7528@TableField(&#8220;&#8221;level&#8221;&#8221;)\u89e3\u51b3 <\/p>\n\n\n\n<p>9\u3001serial\u81ea\u589e\u4e3b\u952e\u548c\u548c\u539f\u6709\u6570\u636e\u51b2\u7a81<\/p>\n\n\n\n<p>10\u3001\u8be6\u7ec6\u793a\u4f8b\uff1a 10.1\u3001mysql\u4e2d\u67e5\u8be2\u4e2d\u5982\u679c\u4f7f\u7528\u53cc\u5f15\u53f7\uff0c\u5728\u4eba\u5927\u91d1\u4ed3\u6570\u636e\u5e93\u4e2d\u4e0d\u652f\u6301\uff0c\u9700\u6539\u4e3a\u5355\u5f15\u53f7 \u4f8b\u5982\uff1aselect \u5b57\u6bb5A\uff0c\u5b57\u6bb5B\uff0c\u5b57\u6bb5C from tableA where \u5b57\u6bb5A = &#8220;1&#8221; \u6539\u4e3a\uff1aselect \u5b57\u6bb5A\uff0c\u5b57\u6bb5B\uff0c\u5b57\u6bb5C from tableA where \u5b57\u6bb5A = &#8216;1&#8217;<\/p>\n\n\n\n<p>10.2\u3001MySQL\u4e2d\u4f7f\u7528group by \u5b57\u6bb5A\uff0c\u7136\u540e\u4e5f\u4f1a\u8fd4\u56de\u5176\u4ed6\u5b57\u6bb5 \u5b57\u6bb5A\uff0c\u5b57\u6bb5B\uff0c\u5b57\u6bb5C\uff0c\u5176\u4ed6\u5b57\u6bb5\u4e5f\u8981\u4f7f\u7528\u51fd\u6570\u62ec\u8d77\u6765\uff0c \u4f8b\u5982\uff1aselect \u5b57\u6bb5A\uff0c\u5b57\u6bb5B\uff0c\u5b57\u6bb5C from tableA group by \u5b57\u6bb5A \u6539\u4e3a\uff1aselect \u5b57\u6bb5A\uff0cmax(\u5b57\u6bb5B) as \u5b57\u6bb5B\uff0cmax(\u5b57\u6bb5C) as \u5b57\u6bb5C from tableA group by \u5b57\u6bb5A \u5426\u5219\u4f1a\u62a5\u9519\uff0c\u8fd9\u4e2a\u95ee\u9898\u53ef\u4ee5\u901a\u8fc7\u914d\u7f6e\uff08\u914d\u7f6e\u540e\u7eed\u8865\u5145\uff09\u4eba\u5927\u91d1\u4ed3\u6570\u636e\u5e93\u89e3\u51b3<\/p>\n\n\n\n<p>10.3\u3001mysql\u4e2d\u4f7f\u7528inner join\u7684\uff0c\u8981\u53bb\u6389\u6539\u4e3a\u4f7f\u7528\u9017\u53f7\u5173\u8054\uff08\u6ce8\uff1a\u5de6\u8fde\u63a5\u548c\u53f3\u8fde\u63a5\u6ca1\u95ee\u9898\uff09 \u4f8b\u5982\uff1aselect a.* from tableA a inner join tableB b on a.\u5b57\u6bb51 = b.\u5b57\u6bb51 \u6539\u4e3a\uff1aselect a.* from tableA a, tableB b where a.\u5b57\u6bb51 = b.\u5b57\u6bb51 10.4\u3001mysql\u7684UUID()\u51fd\u6570\u5728\u4eba\u5927\u91d1\u4ed3\u6570\u636e\u5e93\u4e2d\u4e0d\u652f\u6301<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\u6536\u96c6\u6765\u6e90\uff1a<a href=\"https:\/\/blog.csdn.net\/NN2016160626\/article\/details\/135556355\">https:\/\/blog.csdn.net\/NN2016160626\/article\/details\/135556355<\/a> <\/p>\n\n\n\n<p>\u6536\u96c6\u6765\u6e901: <a href=\"https:\/\/www.jianshu.com\/p\/1f8b8b76d00b\">https:\/\/www.jianshu.com\/p\/1f8b8b76d00b<\/a> <\/p>\n\n\n\n<p>\u6536\u96c6\u6765\u6e90\uff1a\u767e\u5ea6AI-> \u91d1\u4ed3\u6570\u636e\u5e93\u4e0eMySQL\u4e0d\u517c\u5bb9\u5217\u8868 <\/p>\n\n\n\n<p>\u8f6c\u8f7d\u94fe\u63a5\uff1a<a href=\"https:\/\/simonsu.cn\/p\/1101\/\">https:\/\/simonsu.cn\/p\/1101\/<\/a><\/p>\n<\/blockquote>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u56e0\u624b\u4e0a\u7684\u67d0\u9879\u76ee\u9700\u8981\u8fc1\u81f3\u653f\u52a1\u4e91\uff0c\u5168\u9762\u91c7\u7528\u56fd\u4ea7\u5316\u8f6f\u4ef6\u3002\u8fd9\u91cc\u8bb0\u5f55\u4e00\u4e0b\u5c06Mysql\u8fc1\u81f3\u4eba\u5927\u91d1\u4ed3\u6570\u636e\u5e93V8R6\uff08\u662f\u6307V0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37,36,35],"tags":[],"class_list":["post-234","post","type-post","status-publish","format-standard","hentry","category-mysql","category-36","category-35"],"_links":{"self":[{"href":"http:\/\/www.syh.ac.cn\/index.php\/wp-json\/wp\/v2\/posts\/234"}],"collection":[{"href":"http:\/\/www.syh.ac.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.syh.ac.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.syh.ac.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.syh.ac.cn\/index.php\/wp-json\/wp\/v2\/comments?post=234"}],"version-history":[{"count":1,"href":"http:\/\/www.syh.ac.cn\/index.php\/wp-json\/wp\/v2\/posts\/234\/revisions"}],"predecessor-version":[{"id":235,"href":"http:\/\/www.syh.ac.cn\/index.php\/wp-json\/wp\/v2\/posts\/234\/revisions\/235"}],"wp:attachment":[{"href":"http:\/\/www.syh.ac.cn\/index.php\/wp-json\/wp\/v2\/media?parent=234"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.syh.ac.cn\/index.php\/wp-json\/wp\/v2\/categories?post=234"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.syh.ac.cn\/index.php\/wp-json\/wp\/v2\/tags?post=234"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}