'TDengine database escaping characters
I was trying to add some special characters in TDengine's binary string but I'm uncertain about the rule how TDengine processing escape characters, for example inserting the '\t'(tab) and '\v'(vertical tab) behave differently in terms of output. Can anyone help explaining the escaping rule or what common escaping characters supported in popular DBs?
insert into tb values (now ,2 ,'\t');
insert into tb values (now ,2 ,'\\t');
insert into tb values (now ,2 ,'\\\t');
-----------------------------------------
select * from tb;
ts | id | chars |
=========================================================================
2021-08-19 19:48:05.494 | 1 | |
2021-08-19 19:48:19.449 | 2 | t |
2021-08-19 19:48:26.870 | 2 | |
Query OK, 4 row(s) in set (0.005654s)
insert into tb values (now ,2 ,'\v');
insert into tb values (now ,2 ,'\\v');
insert into tb values (now ,2 ,'\\\v');
-----------------------------------------
taos> select * from tb;
ts | id | chars |
=========================================================================
2021-08-19 19:52:36.287 | 2 | v |
2021-08-19 19:52:44.791 | 2 | v |
2021-08-19 19:52:48.934 | 2 | v |
Solution 1:[1]
In TDengine, there is a Special Character Escape Sequences. For details: https://www.taosdata.com/docs/cn/v2.0/taos-sql
Escape character usage rules:
The escape characters that in a identifier (database name, table name, column name):
1. Normal identifier? The wrong identifier is prompted directly, because the identifier must be numbers, letters and underscores, and cannot start with a number.
2. Backquote`` identifier? Keep it as it is.
The escape characters that in a data:
1. The escape character defined above will be escaped (% and _ see the description below). If there is no matching escape character, the escape character will be ignored.
2. 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.If you use \% or \_ outside of pattern-matching contexts, they evaluate to the strings \% and \_, not to % and _.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ming |
