mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 05:22:25 +01:00
b186b4f27a
New test for string functions
62 lines
2.3 KiB
Text
62 lines
2.3 KiB
Text
hello 'hello' ""hello"" 'h'e'l'l'o' hel"lo hel'lo
|
|
hello 'hello' ""hello"" 'h'e'l'l'o' hel"lo hel'lo
|
|
hello
|
|
hellomonty
|
|
length('\n\t\r\b\0\_\%\\')
|
|
10
|
|
concat('monty',' was here ','again') length('hello') char(ascii('h'))
|
|
monty was here again 5 h
|
|
locate('he','hello') locate('he','hello',2) locate('lo','hello',2)
|
|
1 0 4
|
|
instr('hello','he')
|
|
1
|
|
position('ll' in 'hello') position('a' in 'hello')
|
|
3 0
|
|
left('hello',2) right('hello',2) substring('hello',2,2) mid('hello',1,5)
|
|
he lo el hello
|
|
concat('',left(right(concat('what ',concat('is ','happening')),9),4),'',substring('monty',5,1))
|
|
happy
|
|
substring_index('www.tcx.se','.',-2) substring_index('www.tcx.se','.',1)
|
|
tcx.se www
|
|
substring_index('www.tcx.se','tcx',1) substring_index('www.tcx.se','tcx',-1)
|
|
www. .se
|
|
substring_index('.tcx.se','.',-2) substring_index('.tcx.se','.tcx',-1)
|
|
tcx.se .se
|
|
concat(':',ltrim(' left '),':',rtrim(' right '),':')
|
|
:left : right:
|
|
concat(':',trim(LEADING FROM ' left'),':',trim(TRAILING FROM ' right '),':')
|
|
:left: right:
|
|
concat(':',trim(' m '),':',trim(BOTH FROM ' y '),':',trim('*' FROM '*s*'),':')
|
|
:m:y:s:
|
|
concat(':',trim(BOTH 'ab' FROM 'ababmyabab'),':',trim(BOTH '*' FROM '***sql'),':')
|
|
:my:sql:
|
|
concat(':',trim(LEADING '.*' FROM '.*my'),':',trim(TRAILING '.*' FROM 'sql.*.*'),':')
|
|
:my:sql:
|
|
insert('txs',2,1,'hi') insert('is ',4,0,'a') insert('txxxxt',2,4,'es')
|
|
this is a test
|
|
replace('aaaa','a','b') replace('aaaa','aa','b') replace('aaaa','a','bb') replace('aaaa','','b') replace('bbbb','a','c')
|
|
bbbb bb bbbbbbbb aaaa bbbb
|
|
replace(concat(lcase(concat('THIS',' ','IS',' ','A',' ')),ucase('false'),' ','test'),'FALSE','REAL')
|
|
this is a REAL test
|
|
soundex('') soundex('he') soundex('hello all folks')
|
|
H000 H4142
|
|
password('test') length(encrypt('test')) encrypt('test','aa')
|
|
378b243e220ca493 13 aaqPiZY5xR5l.
|
|
md5('hello')
|
|
5d41402abc4b2a76b9719d911017c592
|
|
repeat('monty',5) concat('*',space(5),'*')
|
|
montymontymontymontymonty * *
|
|
reverse('abc') reverse('abcd')
|
|
cba dcba
|
|
rpad('a',4,'1') rpad('a',4,'12') rpad('abcd',3,'12')
|
|
a111 a121 abc
|
|
lpad('a',4,'1') lpad('a',4,'12') lpad('abcd',3,'12')
|
|
111a 121a abc
|
|
rpad(741653838,17,'0') lpad(741653838,17,'0')
|
|
74165383800000000 00000000741653838
|
|
rpad('abcd',7,'ab') lpad('abcd',7,'ab')
|
|
abcdaba abaabcd
|
|
rpad('abcd',1,'ab') lpad('abcd',1,'ab')
|
|
a a
|
|
LEAST(NULL,'HARRY','HARRIOT',NULL,'HAROLD') GREATEST(NULL,'HARRY','HARRIOT',NULL,'HAROLD')
|
|
HAROLD HARRY
|