函数介绍
函数是指一段可以直接被另一段程序调用的程序或代码
函数的分类
1.字符串函数
2.数值函数
3.日期函数
4.流程函数
字符串函数
# 字符串拼接
select concat( 'hello ', 'world' );
# 字符串全部转为小写
select lower( 'HELLO' );
# 字符串全部转为大写
select upper( 'hello' );
# 左填充
select lpad( '12', 5, '0' );
# 右填充
select rpad( '12', 5, '-' );
# 去除左右空格
select trim( ' hello world ' );
# 获取子字符串
select substring( 'hello world', 1, 5 );
练习
# 将emp表中的workno统一为五位数,不足前面补0
update emp set workno = lpad( workno, 5, '0' );
select * from emp;