mysql 修改sql_mode 实现字符串管道‘||’连接

mysql> show variables like '%sql_mode%';
+---------------+--------------------------------------------+
| Variable_name | Value                                      |
+---------------+--------------------------------------------+
| sql_mode      | STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION |
+---------------+--------------------------------------------+
1 row in set (0.00 sec)


mysql> select 'a'||'a';
+----------+
| 'a'||'a' |
+----------+
|        0 |
+----------+
1 row in set, 2 warnings (0.00 sec)


在oracle 缺省支持 通过 ‘ || ’ 来实现字符串拼接,但在mysql 缺省不支持。需要调整mysql 的sql_mode 模式:pipes_as_concat 来实现oracle 的一些功能


mysql> set session sql_mode='STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,pipes_as_concat';
Query OK, 0 rows affected (0.00 sec)


mysql> select 'a'||'a';
+----------+
| 'a'||'a' |
+----------+
| aa       |
+----------+
1 row in set (0.00 sec)


mysql> 

你可能感兴趣的:(验证实验)