{"id":1598,"date":"2022-11-19T17:19:10","date_gmt":"2022-11-19T09:19:10","guid":{"rendered":"https:\/\/qaqaq.top\/?p=1598"},"modified":"2022-11-27T12:40:57","modified_gmt":"2022-11-27T04:40:57","slug":"%e5%ad%97%e7%ac%a6%e9%9b%86%e7%9a%84%e4%bf%ae%e6%94%b9%e4%b8%8e%e5%ba%95%e5%b1%82%e5%8e%9f%e7%90%86%e8%af%b4%e6%98%8e%e3%80%81%e6%af%94%e8%be%83%e8%a7%84%e5%88%99_%e8%af%b7%e6%b1%82%e5%88%b0%e5%93%8d","status":"publish","type":"post","link":"https:\/\/qaqaq.top\/?p=1598","title":{"rendered":"\u5b57\u7b26\u96c6\u7684\u4fee\u6539\u4e0e\u5e95\u5c42\u539f\u7406\u8bf4\u660e\u3001\u6bd4\u8f83\u89c4\u5219_\u8bf7\u6c42\u5230\u54cd\u5e94\u8fc7\u7a0b\u4e2d\u7684\u7f16\u7801\u4e0e\u89e3\u7801\u8fc7\u7a0b\u3001SQL\u5927\u5c0f\u5199\u89c4\u8303\u4e0esql_mode\u7684\u8bbe\u7f6e"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code># \u7b2c01\u7ae0_Linux\u4e0bMySQL\u7684\u5b89\u88c5\u4e0e\u4f7f\u7528\r\n\r\n# 5. \u5b57\u7b26\u96c6\u7684\u76f8\u5173\u64cd\u4f5c\r\n\r\n# \u5b57\u7b26\u96c6\u4e0e\u6bd4\u8f83\u89c4\u5219(\u4e86\u89e3)\r\n\r\n#\u67e5\u770bGBK\u5b57\u7b26\u96c6\u7684\u6bd4\u8f83\u89c4\u5219\r\nSHOW COLLATION LIKE 'gbk%';\r\n\r\n#\u67e5\u770bUTF-8\u5b57\u7b26\u96c6\u7684\u6bd4\u8f83\u89c4\u5219\r\nSHOW COLLATION LIKE 'utf8%';\r\n\r\n\r\n#\u67e5\u770b\u670d\u52a1\u5668\u7684\u5b57\u7b26\u96c6\u548c\u6bd4\u8f83\u89c4\u5219\r\nSHOW VARIABLES LIKE '%_server';\r\n\r\n#\u67e5\u770b\u6570\u636e\u5e93\u7684\u5b57\u7b26\u96c6\u548c\u6bd4\u8f83\u89c4\u5219\r\nSHOW VARIABLES LIKE '%_database';\r\n\r\n#\u67e5\u770b\u5177\u4f53\u6570\u636e\u5e93\u7684\u5b57\u7b26\u96c6\r\nSHOW CREATE DATABASE dbtest1;\r\n\r\n#\u4fee\u6539\u5177\u4f53\u6570\u636e\u5e93\u7684\u5b57\u7b26\u96c6\r\nALTER DATABASE dbtest1 DEFAULT CHARACTER SET 'utf8' COLLATE 'utf8_general_ci';\r\n\r\n\r\n#\u67e5\u770b\u8868\u7684\u5b57\u7b26\u96c6\r\nshow create table emp1;\r\n#\u67e5\u770b\u8868\u7684\u6bd4\u8f83\u89c4\u5219\r\nshow table status from dbtest1 like '%emp1';\r\n#\u4fee\u6539\u8868\u7684\u5b57\u7b26\u96c6\u548c\u6bd4\u8f83\u89c4\u5219\r\nALTER TABLE emp1 DEFAULT CHARACTER SET 'utf8' COLLATE 'utf8_general_ci';\r\n\r\n# 6. SQL\u5927\u5c0f\u5199\u89c4\u8303\r\n\r\n# Windows\u548cLinux\u5e73\u53f0\u533a\u522b\r\n\r\nSHOW VARIABLES LIKE '%lower_case_table_names%';\r\n\r\nUSE dbtest1;\r\n\r\nUSE dBtest1;\r\n\r\nSELECT * FROM emp1;\r\n\r\nSELECT * FROM Emp1;\r\n\r\n# 7. sql_mode\u7684\u5408\u7406\u8bbe\u7f6e\r\n\r\n# \u6a21\u5f0f\u67e5\u770b\u548c\u8bbe\u7f6e\r\n\r\nselect @@session.sql_mode;\r\n\r\nCREATE TABLE mytb12(\r\n    id INT,\r\n    NAME VARCHAR(16),\r\n    age INT,\r\n    dept INT\r\n);\r\n\r\nINSERT INTO mytb12 VALUES(1,'zhang3',33,101);\r\nINSERT INTO mytb12 VALUES(2,'li4',34,101);\r\nINSERT INTO mytb12 VALUES(3,'wang5',34,102);\r\nINSERT INTO mytb12 VALUES(4,'zhao6',34,102);\r\nINSERT INTO mytb12 VALUES(5,'tian7',36,102);\r\n\r\n#\u67e5\u8be2\u6bcf\u4e2a\u90e8\u95e8\u5e74\u9f84\u6700\u5927\u7684\u4eba\r\nSELECT NAME,dept,MAX(age)\r\nFROM mytb12\r\nGROUP BY dept;\r\n\r\n#\u8bbe\u7f6esql_mode\u4e3a\u5bbd\u677e\u6a21\u5f0f\r\nSET SESSION sql_mode = '';\r\n\r\nINSERT INTO mytb12(id, NAME, age)\r\nVALUES(7,'Tom','aaa');\r\n\r\nSELECT * FROM mytb12;\r\n\r\nSET SESSION sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[47],"class_list":["post-1598","post","type-post","status-publish","format-standard","hentry","category-mysql-code","tag-mysql"],"_links":{"self":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/1598"}],"collection":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1598"}],"version-history":[{"count":1,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/1598\/revisions"}],"predecessor-version":[{"id":1599,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/1598\/revisions\/1599"}],"wp:attachment":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1598"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1598"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1598"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}