在本文下面的表列出了 DQL 语句和 DML 语句对函数的支持情况。需要注意的是,在 DML 语句中使用函数,不能将其作为主键。

DML 语句支持

类型 是否支持
CONCAT(string2[,...])
INSTR(string,substring)
LCASE(string2)
LEFT(string2,length)
LENGTH(string)
LOAD_FILE(file_name)
LOCATE(substring,string[,start_position])
LPAD(string2,length,pad)
LTRIM(string2)
REPEAT(string2,count)
REPLACE(str,search_str,replace_str)
RPAD(string2,length,pad)
RTRIM(string2)
STRCMP(string1,string2)
SUBSTRING(str,position[,length])
TRIM([[BOTH|LEADING|TRAILING][padding]FROM]string2)
UCASE(string2)
RIGHT(string2,length)
SPACE(count)
ABS(number2)
BIN(decimal_number)
CEILING(number2)
CONV(number2,from_base,to_base)
FLOOR(number2)
FORMAT(number,decimal_places)
HEX(DecimalNumber)
LEAST(number,number2[,..])
MOD(numerator,denominator)
POWER(number,power)
RAND([seed])
ROUND(number[,decimals])
SIGN(number2)
SQRT(number2)
ADDTIME(date2,time_interval)
CONVERT_TZ(datetime2,fromTZ,toTZ)
CURRENT_DATE()
CURRENT_TIME()
CURRENT_TIMESTAMP()
DATE(datetime)
DATE_ADD(date2,INTERVALd_valued_type)
DATE_FORMAT(datetime,FormatCodes)
DATE_SUB(date2,INTERVALd_valued_type)
DATEDIFF(date1,date2)
DAY(date)
DAYNAME(date)
DAYOFWEEK(date)
DAYOFYEAR(date)
EXTRACT(interval_nameFROMdate)
MAKEDATE(year,day)
MAKETIME(hour,minute,second)
MONTHNAME(date)
NOW()
SEC_TO_TIME(seconds)
STR_TO_DATE(string,format)
TIMEDIFF(datetime1,datetime2)
TIME_TO_SEC(time)
WEEK(date_time[,start_of_week])
YEAR(datetime)
DAYOFMONTH(datetime)
HOUR(datetime)
LAST_DAY(date)
MICROSECOND(datetime)
MONTH(datetime)
MINUTE(datetime)
FIRST()
LAST()
MIN()
MAX()
AVG()
SUM()
COUNT()

DQL 语句支持

类型 读未提交 读已提交
CONCAT(string2[,...])
INSTR(string,substring)
LCASE(string2)
LEFT(string2,length)
LENGTH(string)
LOAD_FILE(file_name)
LOCATE(substring,string[,start_position])
LPAD(string2,length,pad)
LTRIM(string2)
REPEAT(string2,count)
REPLACE(str,search_str,replace_str)
RPAD(string2,length,pad)
RTRIM(string2)
STRCMP(string1,string2)
SUBSTRING(str,position[,length])
TRIM([[BOTH|LEADING|TRAILING][padding]FROM]string2)
UCASE(string2)
RIGHT(string2,length)
SPACE(count)
ABS(number2)
BIN(decimal_number)
CEILING(number2)
CONV(number2,from_base,to_base)
FLOOR(number2)
FORMAT(number,decimal_places)
HEX(DecimalNumber)
LEAST(number,number2[,..])
MOD(numerator,denominator)
POWER(number,power)
RAND([seed])
ROUND(number[,decimals])
SIGN(number2)
SQRT(number2)
ADDTIME(date2,time_interval)
CONVERT_TZ(datetime2,fromTZ,toTZ)
CURRENT_DATE()
CURRENT_TIME()
CURRENT_TIMESTAMP()
DATE(datetime)
DATE_ADD(date2,INTERVALd_valued_type)
DATE_FORMAT(datetime,FormatCodes)
DATE_SUB(date2,INTERVALd_valued_type)
DATEDIFF(date1,date2)
DAY(date)
DAYNAME(date)
DAYOFWEEK(date)
DAYOFYEAR(date)
EXTRACT(interval_nameFROMdate)
MAKEDATE(year,day)
MAKETIME(hour,minute,second)
MONTHNAME(date)
NOW()
SEC_TO_TIME(seconds)
STR_TO_DATE(string,format)
TIMEDIFF(datetime1,datetime2)
TIME_TO_SEC(time)
WEEK(date_time[,start_of_week])
YEAR(datetime)
DAYOFMONTH(datetime)
HOUR(datetime)
LAST_DAY(date)
MICROSECOND(datetime)
MONTH(datetime)
MINUTE(datetime)
FIRST()
LAST()
MIN()
MAX()
AVG()
SUM()
COUNT()