[英]How to replace numbers in SQL
我的数据库有很多相似的描述,我想将它们组合在一起,但由于数字不同,它们并没有组合在一起。 那么有什么方法可以掩盖数字并使描述相同。
我们可以在Excel或Notepad ++中使用find和replace来实现,所以无论如何它都可以在SQL中实现。 我知道我们可以使用该函数替换SQL
REPLACE('column', 'new input', 'to be replaced')
但是如何为正则表达式做,因为数字可以是任意组合。
我正在使用PostgreSQL。
一些意见: -
sample input description 123
sample input description 456
this is another description 678
this is another description 999
我想将它们转换为: -
sample input description xxx
sample input description xxx
this is another description xxx
this is another description xxx
数字可以在任何地方。
我是在红移上做的。
您可以使用以下格式的REGEXP_REPLACE函数。
select regexp_replace ( columnthatneedtomask,'[0-9]','x' ) from table ;
请参阅以下链接以获取更多信息: -
https://docs.aws.amazon.com/redshift/latest/dg/REGEXP_REPLACE.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.