Miac

MySQL version:8.0.18-commercial MySQL Enterprise Server - Commercial

正常查询GTID 是一间比较麻烦的事情
查询结果如下:

mysql> select @@gtid_purged,@@gtid_executed;
+------------------------------------------------------------------------------------------------------------------------------------------------+-----------------+
| @@gtid_purged                                                                                                                                  | @@gtid_executed |
+------------------------------------------------------------------------------------------------------------------------------------------------+-----------------+
| 5e4a0caf-75f9-11e9-9b95-fa163ec02d40:1-1005397,
660e027b-265b-11e8-92e9-fa163ee86ec3:1-893898218,
9310c9c3-2035-11e8-af8e-fa163e3facf6:1-16617 |                 |
+------------------------------------------------------------------------------------------------------------------------------------------------+-----------------+
1 row in set, 1 warning (0.00 sec)

去除换行和回车后:

mysql> select replace(@@gtid_purged,char(10),\'\'),@@gtid_executed;
+----------------------------------------------------------------------------------------------------------------------------------------------+-----------------+
| replace(@@gtid_purged,char(10),\'\')                                                                                                           | @@gtid_executed |
+----------------------------------------------------------------------------------------------------------------------------------------------+-----------------+
| 5e4a0caf-75f9-11e9-9b95-fa163ec02d40:1-1005397,660e027b-265b-11e8-92e9-fa163ee86ec3:1-893898218,9310c9c3-2035-11e8-af8e-fa163e3facf6:1-16617 |                 |
+----------------------------------------------------------------------------------------------------------------------------------------------+-----------------+
1 row in set, 1 warning (0.02 sec)

mysql> select replace(replace(@@gtid_purged,char(10),\'\'),char(13),\'\'),@@gtid_executed;
+----------------------------------------------------------------------------------------------------------------------------------------------+-----------------+
| replace(replace(@@gtid_purged,char(10),\'\'),char(13),\'\')                                                                                      | @@gtid_executed |
+----------------------------------------------------------------------------------------------------------------------------------------------+-----------------+
| 5e4a0caf-75f9-11e9-9b95-fa163ec02d40:1-1005397,660e027b-265b-11e8-92e9-fa163ee86ec3:1-893898218,9310c9c3-2035-11e8-af8e-fa163e3facf6:1-16617 |                 |
+----------------------------------------------------------------------------------------------------------------------------------------------+-----------------+
1 row in set, 1 warning (0.00 sec)

这样看起来就很爽了。。有木有
正常情况下char(10)是换行键,char(13)是回车键

测试如下:

换行:
mysql> select concat(\'A\',char(10),\'B\');
+--------------------------+
| concat(\'A\',char(10),\'B\') |
+--------------------------+
| A
B                      |
+--------------------------+
1 row in set (0.03 sec)
回车:
mysql> select concat(\'A\',char(13),\'B\');
+--------------------------+
| concat(\'A\',char(13),\'B\') |
+--------------------------+
B                      |
+--------------------------+
1 row in set (0.00 sec)
咦.....A不见了.....
查看下length
mysql> select length(\'A\');
+-------------+
| length(\'A\') |
+-------------+
|           1 |
+-------------+
1 row in set (0.01 sec)

mysql> select length(concat(\'A\',char(13)));
+------------------------------+
| length(concat(\'A\',char(13))) |
+------------------------------+
|                            2 |
+------------------------------+
1 row in set (0.00 sec)
其中char(13)的length 是1,`length(concat(\'A\',char(13)))` 应该是有结果的
mysql> select length(concat(char(13)));
+--------------------------+
| length(concat(char(13))) |
+--------------------------+
|                        1 |
+--------------------------+
1 row in set (0.00 sec)

不服。。。用navicat再看下

额。。。

行吧。。。估计在xshell 里面看,就那样了。。其实A还在

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-12-29
  • 2022-02-18
  • 2021-12-13
  • 2022-01-28
  • 2022-01-05
猜你喜欢
  • 2021-09-23
  • 2021-10-09
  • 2021-09-01
相关资源
相似解决方案