i have a value
'sam/le' length --> 6
'add\$io&alsample' length --> 16
i need to replace all characters as '*'
i used select regexp_replace(substr('asdfasdndfs',4),'\w','*')
it only replaces alphabets
desired output
id | col | replaced col |
---|---|---|
1 | sam/le | ****** |
2 | add$io&alsample | **************** |
CodePudding user response:
lpad('' -- start with empty string
,len(yourColumn) -- pad to the length of your column text
,'*' -- with asterisks
)
CodePudding user response:
Using REPEAT:
SELECT id, col, REPEAT('*', LEN(col))
FROM tab
CodePudding user response:
If you are actually wanting to make the update after adding that as a new column:
UPDATE strings SET replaced_col = LPAD('', CHAR_LENGTH(col), '*')