当使用带有sql-command-line-client的select时,如何在String中看到空格?
我的意思是以下内容.你有三条线.1,2和3个空格.你没有机会看到空格的数量.
create table foo(bar varchar(8));
insert into foo values(" "),(" "), (" ");
select * from foo\g
+------+
| bar |
+------+
| |
| |
| |
+------+
mysql> select * from foo\G
*************************** 1. row ***************************
bar:
*************************** 2. row ***************************
bar:
*************************** 3. row ***************************
bar:
3 rows in set (0.01 sec)
Run Code Online (Sandbox Code Playgroud)
我想出的唯一选择是:
mysql> select bar, hex(bar) from foo;
+------+----------+
| bar | hex(bar) |
+------+----------+
| | 20 |
| | 2020 |
| | 202020 |
+------+----------+
3 rows in set (0.01 sec)
Run Code Online (Sandbox Code Playgroud)
像php中的var_export这样的东西会很好.
jen*_*ens 14
它似乎有一个字符串函数QUOTE(Escape在SQL语句中使用的参数),它非常好用.
-- to add another tricky example
mysql> insert into foo values(" \" ' "), ("''");
Query OK, 1 row affected (0.06 sec)
mysql> select bar, quote(bar) from foo;
+-------+------------+
| bar | quote(bar) |
+-------+------------+
| | ' ' |
| | ' ' |
| | ' ' |
| " ' | ' " \' ' |
| '' | '\'\'' |
+-------+------------+
4 rows in set (0.00 sec)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3157 次 |
| 最近记录: |