DRDS支持常见的操作符函数、流程控制函数、数学函数、字符串函数和时间函数,汇总如下:
操作符函数
函数表达式 |
函数描述 |
AND, && |
Logical AND |
= |
Assign a value (as part of a SET statement, or as part of the SET clause in an UPDATE statement) |
BETWEEN … AND … |
Check whether a value is within a range of value |
BINARY |
Cast a string to a binary string |
& |
Bitwise AND |
~ |
Bitwise inversion |
^ |
Bitwise XOR |
DIV |
Integer division |
/ |
Division operator |
<=> |
NULL-safe equal to perator |
= |
Equal operator |
>= |
Greater than or equal operator |
> |
Greater than operator |
IS NOT NULL |
NOT NULL value test |
IS NOT |
Test a value against a boolean |
流程控制函数
函数表达式 |
函数描述 |
CASE |
Case operator |
IF() |
If/else construct |
IFNULL() |
Null if/else construct |
NULLIF() |
Return NULL if expr1 = expr2 |
数学函数
函数表达式 |
函数描述 |
CRC32() |
Compute a cyclic redundancy check value |
DEGREES() |
Convert radians to degrees |
DIV |
Intger division |
EXP() |
Raise to the power of |
FLOOR() |
Return the largest integer value not greater than the argument |
LN() |
Return the natural logarithm of the argument |
LOG10() |
Return the base-10 logarithm of the argument |
LOG2() |
Return the base-2 logarithm of the argument |
LOG() |
Return the natural logarithm of the first argument |
MOD() |
Return the remainder |
%, MOD |
Modulo operator |
PI() |
Return the value of pi |
POW() |
Return the argument raised to the specified power |
POWER() |
Return the argument raised to the specified power |
RADIANS() |
Return argument converted to radians |
RAND() |
Return a random floating-point value |
ROUND() |
Round the argument |
SIGN() |
Return the sign of the argument |
SIN() |
Return the sine of the argument |
SQRT() |
Return the square root of the argument |
TAN() |
Return the tangent of the argument |
TRUNCATE( |
Truncate to specified number of decimal places |
字符串函数
函数表达式 |
函数描述 |
ASCII() |
Return numeric value of left-most character |
BIN() |
Return a string containing binary representation of a number |
BIT_LENGTH() |
Return length of argument in bits |
CHAR_LENGTH() |
Return number of characters in argument |
CHAR() |
Return the character for each integer passed |
CHARACTER_LENGTH() |
Synonym for CHAR_LENGTH() |
CONCAT_WS() |
Return concatenate with separator |
CONCAT() |
Return concatenated string |
ELT() |
Return string at index number |
EXPORT_SET() |
Return a string such that for every bit set in the value bits, you get an on string and for every unset bit, you get an off string |
FIELD() |
Return the index (position) of the first argument in the subsequent arguments |
FIND_IN_SET() |
Return the index position of the first argument within the second argument |
FORMAT() |
Return a number formatted to specified number of decimal places |
HEX() |
Return a hexadecimal representation of a decimal or string value |
INSERT() |
Insert a substring at the specified position up to the specified number of characters |
INSTR() |
Return the index of the first occurrence of substring |
LCASE() |
Synonym for LOWER() |
时间函数
函数表达式 |
函数描述 |
DATE_ADD() |
Add time values (intervals) to a date value |
DATE_FORMAT() |
Format date as specified |
DATE_SUB() |
Subtract a time value (interval) from a date |
DATE() |
Extract the date part of a date or datetime expression |
DATEDIFF() |
Subtract two dates |
DAY() |
Synonym for DAYOFMONTH() |
DAYNAME() |
Return the name of the weekday |
DAYOFMONTH() |
Return the day of the month (0-31) |
DAYOFWEEK() |
Return the weekday index of the argument |
DAYOFYEAR() |
Return the day of the year (1-366) |
EXTRACT() |
Extract part of a date |
FROM_DAYS() |
Convert a day number to a date |
FROM_UNIXTIME() |
Format UNIX timestamp as a date |
GET_FORMAT() |
Return a date format string |
HOUR() |
Extract the hour |
LAST_DAY() |
Return the last day of the month for the argument |
LOCALTIME() |
LOCALTIME Synonym for NOW() |
LOCALTIMESTAMP, LOCALTIMESTAMP() |
Synonym for NOW() |
MAKEDATE() |
Create a date from the year and day of year |
MAKETIME() |
Create time from hour, minute, second |
MICROSECOND() |
Return the microseconds from argument |
MINUTE() |
Return the minute from the argument |