在 oracle 11g 中,如何将列中的字符数据转换[a-z][A-Z]
为某个随机字符 x。例如:如果我的源列数据是 tom,那么我应该得到 xxx,如果我的源列数据是 lilly,那么我应该得到 xxxxx。
问问题
263 次
2 回答
1
你可以写:
REGEXP_REPLACE(name_of_source_column, '[a-zA-Z]', 'x')
AS source_column_with_letters_replaced_by_x
(当然,除了那source_column_with_letters_replaced_by_x
不是 Oracle 中的有效标识符)。
于 2012-10-16T21:25:58.097 回答
1
SELECT dbms_random.string( 'A', length( <<input string>> ))
FROM dual
将返回一个随机的、大小写混合的字母字符字符串,长度为<<input string>>
. 我想这就是你要找的。但是,我不清楚您的问题是否只想替换源字符串中的字母字符。也就是说,如果输入字符串是“Tom4Jerry”,您是否希望输出为“xxx4xxxxxx”,其中 x 是随机字符?或者你想要“xxxxxxxxx”?
于 2012-10-16T21:27:16.000 回答