📄 function.txt
字号:
REPLACE(str,from_str,to_str)|Returns the string str with all all occurrences of the string from_str replaced by the string to_str.
REVERSE(str)|Returns the string str with the order of the characters reversed.
RIGHT(str,len)|Returns the rightmost len characters from the string str.
RPAD(str,len,padstr)|Returns the string str, right-padded with the string padstr until str is len characters long.
RTRIM(str)|Returns the string str with trailing space characters removed.
SOUNDEX(str)|Returns a soundex string from str. Two strings that sound "about the same" should have identical soundex strings.
SPACE(N)|Returns a string consisting of N space characters.
SUBSTRING(str,pos,len)|Returns a substring len characters long from string str, starting at position pos.
SUBSTRING_INDEX(str,delim,count)|Returns the substring from string str before count occurrences of the delimiter delim.
TRIM([[BOTH | LEADING | TRAILING] [remstr] FROM] str)|Returns the string str with all remstr prefixes and/or suffixes removed. If none of the specifiers BOTH, LEADING or TRAILING are given, BOTH is assumed.
UCASE(str)|Returns the string str with all characters changed to uppercase according to the current character set mapping (the default is ISO-8859-1 Latin1).
UPPER(str)|Returns the string str with all characters changed to uppercase according to the current character set mapping (the default is ISO-8859-1 Latin1).
Date and Time
ADDDATE(date,INTERVAL expr type)|Performs date arithmetic.
CURDATE()|Returns today's date as a value in "YYYY-MM-DD" or YYYYMMDD format, depending on whether the function is used in a string or numeric context.
CURTIME()|Returns the current time as a value in "HH:MM:SS" or HHMMSS format, depending on whether the function is used in a string or numeric context.
DATE_ADD(date,INTERVAL expr type)|Performs date arithmetic.
DATE_FORMAT(date,format)|Formats the date value according to the format string.
DATE_SUB(date,INTERVAL expr type)|Performs date arithmetic.
DAYNAME(date)|Returns the name of the weekday for date.
DAYOFMONTH(date)|Returns the day of the month for date, in the range 1 to 31.
DAYOFWEEK(date)|Returns the weekday index for date (1 = Sunday, 2 = Monday, ... 7 = Saturday). These index values correspond to the ODBC standard.
DAYOFYEAR(date)|Returns the day of the year for date, in the range 1 to 366.
EXTRACT
FROM_DAYS(N)|Given a daynumber N, returns a DATE value.
FROM_UNIXTIME(unix_timestamp,format)|Returns a representation of the unix_timestamp argument as a value in "YYYY-MM-DD HH:MM:SS" or YYYYMMDDHHMMSS format, depending on whether the function is used in a string or numeric context.
HOUR(time)|Returns the hour for time, in the range 0 to 23.
MINUTE(time)|Returns the minute for time, in the range 0 to 59.
MONTH(date)|Returns the month for date, in the range 1 to 12.
MONTHNAME(date)|Returns the name of the month for date.
NOW()|Returns the current date and time as a value in "YYYY-MM-DD HH:MM:SS" or YYYYMMDDHHMMSS format, depending on whether the function is used in a string or numeric context.
PERIOD_ADD(P,N)|Adds N months to period P (in the format YYMM or YYYYMM). Returns a value in the format YYYYMM.
PERIOD_DIFF(P1,P2)|Returns the number of months between periods P1 and P2. P1 and P2 should be in the format YYMM or YYYYMM.
QUARTER(date)|Returns the quarter of the year for date, in the range 1 to 4.
SECOND(time)|Returns the minute for time, in the range 0 to 59.
SEC_TO_TIME(seconds)|Returns the seconds argument, converted to hours, minutes and seconds, as a value in "HH:MM:SS" or HHMMSS format, depending on whether the function is used in a string or numeric context.
SUBDATE(date,INTERVAL expr type)|Performs date arithmetic.
SYSDATE()|Returns the current date and time as a value in "YYYY-MM-DD HH:MM:SS" or YYYYMMDDHHMMSS format, depending on whether the function is used in a string or numeric context.
TIME_FORMAT(time,format)|This is used like the DATE_FORMAT() function above, but the format string may contain only those format specifiers that handle hours, minutes and seconds.
TIME_TO_SEC(time)|Returns the time argument, converted to seconds.
TO_DAYS(date)|Given a date date, returns a daynumber (the number of days since year 0).
UNIX_TIMESTAMP(date)|If called with no argument, returns a Unix timestamp (seconds since "1970-01-01 00:00:00" GMT). If UNIX_TIMESTAMP() is called with a date argument, it returns the value of the argument as seconds since "1970-01-01 00:00:00" GMT.
WEEK(date)|With a single argument, returns the week for date, in the range 0 to 53
WEEKDAY(date)|Returns the weekday index for date (0 = Monday, 1 = Tuesday, ... 6 = Sunday).
YEAR(date)|Returns the year for date, in the range 1000 to 9999.
YEARWEEK(date,first)|Returns year and week for a date. The second arguments works exactly like the second argument to WEEK().
Summarizing
AVG(expr)|Returns the average value of expr.
BIT_AND(expr)|Returns the bitwise AND of all bits in expr. The calculation is performed with 64-bit (BIGINT precision).
BIT_OR(expr)|Returns the bitwise OR of all bits in expr. The calculation is performed with 64-bit (BIGINT precision).
COUNT(expr)|Returns a count of the number of non-NULL values in the rows retrieved by a SELECT statement.
MAX(expr)|Returns the maximum value of expr. May take a string argument; in such cases it returns the maximum string value.
MIN(expr)|Returns the minimum value of expr. May take a string argument; in such cases it returns the minimum string value.
STD(expr)|Returns the standard deviation of expr. This is an extension to ANSI SQL. The STDDEV() form of this function is provided for Oracle compatability.
STDDEV(expr)|Returns the standard deviation of expr. This is an extension to ANSI SQL. The STDDEV() form of this function is provided for Oracle compatability.
SUM(expr)|Returns the sum of expr. Note that if the return set has no rows, it returns NULL!
Miscellaneous
BENCHMARK(count,expr)|Executes the expression expr repeatedly count times. It may be used to time how fast MySQL processes the expression.
BIT_COUNT(N)|Returns the number of bits that are set in the argument N.
CONNECTION_ID()|Returns the connection id (thread_id) for the connection. Every connection has its own unique id.
DATABASE()|Returns the current database name.
DECODE(crypt_str,pass_str)|Descrypts the encrypted string crypt_str using pass_str as the password. crypt_str should be a string returned from ENCODE().
ENCODE(str,pass_str)|Encrypt str using pass_str as the password. To decrypt the result, use DECODE(). The results is a binary string of the same length as string. If you want to save it in a column, use a BLOB column type.
ENCRYPT(str[,salt])|Encrypt str using the Unix crypt() system call. The salt argument should be a string with two characters. (As of MySQL 3.22.16, salt may be longer than two characters.)
GET_LOCK(str,timeout)|Tries to obtain a lock with a name given by the string str, with a timeout of timeout seconds. Returns 1 if the lock was obtained successfully, 0 if the attempt timed out, or NULL if an error occurred (such as running out of memory or the thread was killed with mysqladmin kill).
INET_NTOA(expr)|Returns the network address (4 or 8 byte) for the numeric expression.
INET_ATON(expr)|Returns an integer that represents the numeric value for a network address Addresses may be 4 or 8 byte addresses.
LAST_INSERT_ID([expr])|Returns the last automatically generated value that was inserted into an AUTO_INCREMENT column.
LOAD_FILE(file_name)|Reads the file and returns the file contents as a string. The file must be on the server, you must specify the full pathname to the file, and you must have the file privilege.
MD5(string)|Calculates a MD5 checksum for the string. Value is returned as a 32 long hex number that may, for example, be used as a hash key.
PASSWORD(str)|Calculates a password string from the plaintext password str. This is the function that is used for encrypting MySQL passwords for storage in the Password column of the user grant table.
RELEASE_LOCK(str)|Releases the lock named by the string str that was obtained with GET_LOCK(). Returns 1 if the lock was released, 0 if the lock wasn't locked by this thread (in which case the lock is not released) and NULL if the named lock didn't exist.
SESSION_USER()|Returns the current MySQL user name.
SYSTEM_USER()|Returns the current MySQL user name.
USER()|Returns the current MySQL user name.
VERSION()|Returns a string indicating the MySQL server version.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -