MySQLSlashesandBackslashes_MySQL
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了MySQLSlashesandBackslashes_MySQL,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3437字,纯文字阅读大概需要5分钟。
内容图文
![MySQLSlashesandBackslashes_MySQL](/upload/InfoBanner/zyjiaocheng/578/9002f1dc62564d12924f3a7138934598.jpg)
At first I thought this was the ol’ MySQL string literal problem where you need to have twobackslashes to get one backslash in a character field. SeeString Literalsin the MySQL Manual.A lot of people have trouble with the backslash when they first get started with MySQL. From the quote below, you will see that some characters need to be escaped with a backslash. But what about the forward slash?
I remember a previous job were I saved many UNIX file names but I did not remember anything unusual about forward slashed. My mental cache had been flushed of the answer. So I created a test table and experimented.
As can be shown in the image, the ‘//’ trick works for inputting a single backslash. And ‘//’ will input TWO slashes. So their is no trick for fore slashes.
No too bad for a Monday morning with no caffeine.
Within a string, certain sequences have special meaning unless the NO_BACKSLASH_ESCAPES SQL mode is enabled. Each of these sequences begins with a backslash (“/”), known as the escape character. MySQL recognizes the escape sequences shown in Table 9.1, “Special Character Escape Sequences”. For all other escape sequences, backslash is ignored. That is, the escaped character is interpreted as if it was not escaped. For example, “/x” is just “x”. These sequences are case sensitive. For example, “/b” is interpreted as a backspace, but “/B” is interpreted as “B”. Escape processing is done according to the character set indicated by the character_set_connection system variable. This is true even for strings that are preceded by an introduce that indicates a different character set, as discussed in Section 10.1.3.5, “Character String Literal Character Set and Collation”.
Table 9.1 Special Character Escape Sequences
Escape Sequence Character Represented by Sequence
An ASCII NUL (0×00) character.
/’ A single quote (“’”) character.
/” A double quote (“””) character.
/b A backspace character.
/n A newline (linefeed) character.
/r A carriage return character.
/t A tab character.
/Z ASCII 26 (Control+Z). See note following the table.
// A backslash (“/”) character.
/% A “%” character. See note following the table.
/_ A “_” character. See note following the table.
The ASCII 26 character can be encoded as “/Z” to enable you to work around the problem that ASCII 26 stands for END-OF-FILE on Windows. ASCII 26 within a file causes problems if you try to use mysql db_name < file_name.
The “/%” and “/_” sequences are used to search for literal instances of “%” and “_” in pattern-matching contexts where they would otherwise be interpreted as wildcard characters. See the description of the LIKE operator in Section 12.5.1, “String Comparison Functions”. If you use “/%” or “/_” outside of pattern-matching contexts, they evaluate to the strings “/%” and “/_”, not to “%” and “_”.
There are several ways to include quote characters within a string:
A “'” inside a string quoted with “'” may be written as “''”.
A “"” inside a string quoted with “"” may be written as “""”.
Precede the quote character by an escape character (“/”).
A “'” inside a string quoted with “"” needs no special treatment and need not be doubled or escaped. In the same way, “"” inside a string quoted with “'” needs no special treatment.
内容总结
以上是互联网集市为您收集整理的MySQLSlashesandBackslashes_MySQL全部内容,希望文章能够帮你解决MySQLSlashesandBackslashes_MySQL所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。