MySQL functions

GoogleSQL for Spanner supports the following MySQL functions. You need to install the MySQL functions in your Spanner database before you can use them. For more information on installing the functions, see Install MySQL functions.

MySQL function list

Name Summary
mysql.BIN_TO_UUID Converts a binary UUID representation to a STRING representation.
mysql.BIT_LENGTH Returns the length of string in bits.
mysql.CHAR Interprets the input parameter as an integer and returns a byte string consisting of the character given by the code value of that integer.
mysql.CONCAT_WS Returns a concatenated string with separators.
mysql.DATE_FORMAT Formats a date as specified.
mysql.DATEDIFF Subtracts two dates and returns the number of days between them.
mysql.DAY Alias for DAYOFMONTH. Returns the day of the month (1-31) from a TIMESTAMP value.
mysql.DAYNAME Returns the name of the weekday.
mysql.DAYOFMONTH Returns the day of the month (1-31).
mysql.DAYOFWEEK Returns the weekday index of the input parameter.
mysql.DAYOFYEAR Returns the day of the year (1-366).
mysql.DEGREES Converts radians to degrees.
mysql.FROM_DAYS Converts a day number to a date.
mysql.FROM_UNIXTIME Formats a Unix timestamp as a date.
mysql.HEX Returns the hexadecimal representation of a string.
mysql.HOUR Returns the hour (0-23).
mysql.INET_ATON Returns the numeric value of an IP address.
mysql.INET_NTOA Returns the IP address from a numeric value.
mysql.INET6_ATON Returns the numeric value of an IPv6 address.
mysql.INET6_NTOA Returns the IPv6 address from a numeric value.
mysql.INSERT Inserts a substring at a specified position up to a specified number of characters.
mysql.IS_IPV4 Checks whether the input parameter is an IPv4 address.
mysql.IS_IPV4_COMPAT Returns whether the input parameter is an IPv4-compatible address.
mysql.IS_IPV4_MAPPED Returns whether the input parameter is an IPv4-mapped address.
mysql.IS_IPV6 Returns whether the input parameter is an IPv6 address.
mysql.IS_UUID Returns whether the input parameter is a valid UUID. Not available in MySQL 5.7.
mysql.JSON_QUOTE Quotes the JSON document.
mysql.JSON_UNQUOTE Unquotes the JSON value.
mysql.LOCALTIME Alias for NOW. Returns the TIMESTAMP for when the query statement containing this function started to run.
mysql.LOCALTIMESTAMP Returns the TIMESTAMP when the query statement containing this function started to run.
mysql.LOCATE Returns the position of the first occurrence of a substring. The search is case insensitive.
mysql.LOG2 Returns the base-2 logarithm of the input argument. Returns NULL if the input argument is out of range.
mysql.MAKEDATE Creates a date from the year and day of year.
mysql.MICROSECOND Returns the microseconds from the input parameter.
mysql.MID Alias for SUBSTRING.
mysql.MINUTE Returns the minute from the input parameter.
mysql.MONTH Returns the month from the date passed.
mysql.MONTHNAME Returns the name of the month.
mysql.NOW Returns the TIMESTAMP when the query statement containing this function started to run.
mysql.OCT Returns a string containing an octal representation of a number.
mysql.ORD Returns the character code for the leftmost character of the input parameter.
mysql.PERIOD_ADD Adds a period to a year-month.
mysql.PERIOD_DIFF Returns the number of months between periods.
mysql.PI Returns the value of pi.
mysql.POSITION Alias for LOCATE. Returns the starting position of the first occurrence of the substring.
mysql.QUARTER Returns the quarter from a date input parameter.
mysql.QUOTE Escapes the input parameter for use in a SQL statement.
mysql.RADIANS Converts degrees to radians.
mysql.REGEXP_LIKE Returns TRUE if the string matches a regular expression. Not available in MySQL 5.7.
mysql.REGEXP_SUBSTR Returns a substring matching a regular expression. Not available in MySQL 5.7.
mysql.SECOND Returns the second (0-59).
mysql.SHA2 Calculates a SHA-2 checksum.
mysql.SPACE Returns a string of the specified number of spaces.
mysql.STR_TO_DATE Converts a string to a date.
mysql.STRCMP Compares two strings.
mysql.SUBSTRING_INDEX Returns a substring from a string before the specified number of occurrences of the delimiter. Performs a case-sensitive match when searching for the delimiter.
mysql.SYSDATE Returns the TIMESTAMP when the query statement containing this function started to run.
mysql.TIME Extracts the time portion of the expression passed.
mysql.TO_DAYS Returns the date input parameter converted to days.
mysql.TO_SECONDS Returns the date or datetime input parameter converted to seconds since Year 0.
mysql.TRUNCATE Truncates a number to a specified number of decimal places.
mysql.UNHEX Returns a string containing the hex representation of a number.
mysql.UNIX_TIMESTAMP Returns a Unix timestamp.
mysql.UTC_DATE Returns the current UTC date.
mysql.UTC_TIMESTAMP Returns the TIMESTAMP when the query statement containing this function started to run.
mysql.UUID Returns a Universal Unique Identifier (UUID).
mysql.UUID_TO_BIN Converts a string representation of a UUID to a binary representation.
mysql.WEEK Returns the week number.
mysql.WEEKDAY Returns the weekday index.
mysql.WEEKOFYEAR Returns the calendar week of the date (1-53).
mysql.YEAR Returns the year.