- 类别:
RANDSTR¶
返回指定长度 ( length
) 的随机字符串。
语法¶
RANDSTR( <length> , <gen> )
使用说明¶
各个字符是从以下字符池中均匀地随机选择的:0-9、a-z、A-Z。
生成器表达式
gen
的值用作此均匀随机分布的种子。有关生成器表达式的更多信息,请参阅 使用说明。
示例¶
SELECT randstr(5, random()) FROM table(generator(rowCount => 5));
+----------------------+
| RANDSTR(5, RANDOM()) |
|----------------------|
| rM6ep |
| nsWJ0 |
| IQi5H |
| VBNvY |
| wjk6y |
+----------------------+
SELECT randstr(5, 1234) FROM table(generator(rowCount => 5));
+------------------+
| RANDSTR(5, 1234) |
|------------------|
| E5tav |
| E5tav |
| E5tav |
| E5tav |
| E5tav |
+------------------+
SELECT randstr(abs(random()) % 10, random()) FROM table(generator(rowCount => 5));
+---------------------------------------+
| RANDSTR(ABS(RANDOM()) % 10, RANDOM()) |
|---------------------------------------|
| e |
| iR |
| qRwWl7W6 |
| |
| Yg |
+---------------------------------------+