Skip to content

version_minor()

xiaoboluo768 edited this page Jun 9, 2020 · 2 revisions
  • 通过version()函数获取并返回MySQL server的次要版本号,该函数在MySQL 5.7.9中新增

    • 该函数执行时无需传入任何参数
  • 返回值:一个TINYINT UNSIGNED值

  • 定义语句

DROP FUNCTION IF EXISTS version_minor;

DELIMITER $$

CREATE DEFINER='root'@'localhost' FUNCTION version_minor ()
    RETURNS TINYINT UNSIGNED
    COMMENT '
            Description
            -----------

            Returns the minor (release series) version of MySQL Server.

            Returns
            -----------

            TINYINT UNSIGNED

            Example
            -----------

            mysql> SELECT VERSION(), sys.server_minor();
            +--------------------------------------+---------------------+
            | VERSION()                            | sys.version_minor() |
            +--------------------------------------+---------------------+
            | 5.7.9-enterprise-commercial-advanced | 7                  |
            +--------------------------------------+---------------------+
            1 row in set (0.00 sec)
            '
    SQL SECURITY INVOKER
    NOT DETERMINISTIC
    NO SQL
BEGIN
    RETURN SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING_INDEX(VERSION(), '-', 1), '.', 2), '.', -1);
END$$

DELIMITER ;

上一篇: version_major()函数 | 下一篇: version_patch()函数

Clone this wiki locally