sqle icon indicating copy to clipboard operation
sqle copied to clipboard

将SQLE所有用双引号包裹字符串的地方改为单引号

Open HuangWeiCen opened this issue 2 years ago • 0 comments

背景

SQL语句中需要包裹字符串时请务必使用单引号而非双引号, 因为MySQL的 sql_mode中有一项 'ANSI_QUOTES', 开启后双引号包裹的内容会被当作标识符而非字符串, 从而导致本来正确的sql执行不了

官方文档

MySQL :: MySQL 5.7 Reference Manual :: 5.1.10 Server SQL Modes

测试过程

开启此项后执行SQL的结果如图 origin_img_v2_d8c27657-d64d-40ed-a086-7f3e3c5a844g

关闭此项后执行SQL的结果如图 origin_img_v2_950cd405-0db7-49b7-aeda-a60cc9eeca0g

HuangWeiCen avatar Aug 09 '22 10:08 HuangWeiCen

复现版本: Server Version: release-1.2207.x-ee 018349a02a 复现步骤: 1.开启该项 SET GLOBAL sql_mode = 'ANSI_QUOTES'; 2.使用以下sql语句进行审核,出现错误提示 select TABLE_NAME from information_schema.tables where table_schema="dcisdb02" and TABLE_TYPE in ("BASE TABLE","SYSTEM VIEW"); image

Marcus9530 avatar Sep 02 '22 08:09 Marcus9530

验证版本: Server Version: main-ee c233f3efea 验证步骤: 1.开启该项 SET GLOBAL sql_mode = 'ANSI_QUOTES'; 2.使用以下sql语句进行审核,正常审核 select TABLE_NAME from information_schema.tables where table_schema="dcisdb02" and TABLE_TYPE in ("BASE TABLE","SYSTEM VIEW");

image

Marcus9530 avatar Sep 02 '22 08:09 Marcus9530