CHR(0) in REGEXP_LIKE

前端 未结 3 767
被撕碎了的回忆
被撕碎了的回忆 2021-01-15 08:25

I am using the queries to check how chr(0) behaves in regexp_like.

CREATE TABLE t1(a char(10));
INSERT INTO t1 VALUES(\'0123456789\');
SELECT CASE WHEN REGE         


        
3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-15 09:18

    Aleksej kind of beat me to it, but CHR(0) is the value for the string terminator (kind of like the NULL keyword but not exactly). Think of it like an internal end-of-string indicator that CHR(0) apparently can see. Note that if you try the query with the keyword NULL, it will return zero, as nothing can be compared to NULL and the comparison thus will fail (as you were expecting). Interesting. Perhaps someone more experienced with the internal workings can explain further, I would be interested to hear more.

提交回复
热议问题