MariaDBで乱数を生成する方法
環境
windows 10 64 bit
MariaDB 10.6.4
書式
RAND( )
使用例
1.1~10までの乱数を取得します
MariaDB [(none)]> SELECT CEIL(RAND() * 10); +-------------------+ | CEIL(RAND() * 10) | +-------------------+ | 1 | +-------------------+ 1 row in set (0.105 sec) MariaDB [(none)]> SELECT CEIL(RAND() * 10); +-------------------+ | CEIL(RAND() * 10) | +-------------------+ | 4 | +-------------------+
使用例2
乱数を生成します
MariaDB [(none)]> SELECT RAND(); +--------------------+ | RAND() | +--------------------+ | 0.8920698798187728 | +--------------------+