Mysql err 1055
阿新 • • 發佈:2018-10-30
lin uic order urn affect bsp str bst oracle
目錄:
錯誤信息
原因分析
解決方案
操作示例
- 錯誤信息
[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column ‘information_schema.PROFILING.SEQ‘ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
- 原因分析
Mysql 中的SQL 語法並是嚴格按照SQL 95 標準的。在聚合操作時,group by 允許不包含所有select的非聚合 列. mysql 提供了一個參數可以使SQL 嚴格按照SQL 95標準編寫,但是同時此參數是存在缺陷的。一些delete 等非聚合操作,從java 客戶端發起時,有可能會引起錯誤:[err] 1055.
- 解決方案
簡單的解決方案就是取消此參數設置。參數的設置方法如下:
# 臨時調整 set @@sql_mode=‘參數列表,以逗號分隔‘ 或者 set global sql_mode=‘參數列表,以逗號分隔‘ # 永久調整 修改參數配置文件my.cnf sql_mode = ‘參數列表,不同參數之間以逗號分隔‘
- 示例
- 臨時修改示例
mysql> set global sql_mode=‘STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION‘; Query OK, 0 rows affected (0.00 sec) mysql> exit Bye [root@test ~]# mysql -D Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1814164 Server version: 5.7.17 MySQL Community Server (GPL) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql> select @@sql_mode; +------------------------------------------------------------------------------------------------------------------------+ | @@sql_mode | +------------------------------------------------------------------------------------------------------------------------+ | STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION | +------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
- 永久修改示例
# 修改之前 sql_mode=‘ONLY_FULL_GROUP_BY,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION‘ # 修改之後 sql_mode=‘NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION‘
- 臨時修改示例
Mysql err 1055