# 字符函数
# 大小写、长度、字符连接,字符索引
SELECT LOWER(ename),UPPER(ename) ,LENGTH(ename),CONCAT("$",sal),INSTR(ename,"A")
FROM t_emp;
# 插入
SELECT INSERT("ABCDE",1,0,123456) # 123456ABCDE
SELECT INSERT("ABCDE",1,2,123456) # 123456CDE
# 替换
SELECT REPLACE("ABCDE","CDE","XYZ") AS '字母';
# 提取字段 SUBSTR(字符,起始位置,长度) SUBSTRING(字符,起始位置,偏移值)
SELECT SUBSTR("HELLO WORLD",1,5),SUBSTRING("HELLO WORLD",7,5)
# 填充字符,如添加掩码
SELECT LPAD(SUBSTRING("18620084979",8,4),11,"*");
SELECT RPAD(SUBSTRING("麦志坚",1,1),LENGTH("麦志坚")/3,"*")
# 去除两端空格
SELECT TRIM(" HELLO WORLD ")
# 综合实例
SELECT CONCAT(RPAD(SUBSTRING('478985199511114567',1,6),LENGTH("478985199511"),"*"),"114567");