在MySQL中反斜杠\是否为字符? [英] Is the backslash \ counted as a character in MySQL?

查看:122
本文介绍了在MySQL中反斜杠\是否为字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个表,其中有固定长度的列,我的SQL将反斜杠作为字符计数?



示例:

 人(姓名[10],年龄[3])

如果我在名称列中存储一个MySQL转义的值,如: Blahblah \的
MySQL会在引用吗? p>

感谢

解决方案

否,转义字符不添加 char varchar 字符串,因为转义符不存储。

  CREATE TABLE a(name char(5)); 

INSERT INTO a VALUES('1234567890');
INSERT INTO a VALUES('12 \'345678');

SELECT * FROM a;
+ ------- +
|名称|
+ ------- +
| 12345 |
| 12'34 |
+ ------- +
集合中的2行(0.00秒)


if i have a table which has columns with fixed lenght, Will mySQL count the backslashes as characters?

Example :

people(name[10],age[3])

If i store in the name column a MySQL escaped value like : Blahblah\'s Will MySQL cut it at the quote?

Thanks

解决方案

No, escape characters do not add the length of char or varchar string, because escape characters are not stored at all.

CREATE TABLE a (name char(5));

INSERT INTO a VALUES ('1234567890');
INSERT INTO a VALUES ('12\'345678');

SELECT * FROM a;
+-------+
| name  |
+-------+
| 12345 | 
| 12'34 | 
+-------+
2 rows in set (0.00 sec)

这篇关于在MySQL中反斜杠\是否为字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆