Search code examples
sqloracle-databasesqlitereplaceregexp-replace

Remove numbers found in string column


What would be the SQL to remove all numbers found in an otherwise string column using Sqlite (an Oracle example would be appreciated too)?

Example : I would like to remove all numbers from entries like this :

291 HELP,1456 CALL

Expected output:

HELP,CALL

edit: I have edited the question because it is not only from one entry that I want to remove numbers but many of them.


Solution

  • Either you do it in the language, you embedded sqlite, or you use this SQLite code, that removes all numbers:

    UPDATE table SET column = replace(column, '0', '' );
    UPDATE table SET column = replace(column, '1', '' );
    UPDATE table SET column = replace(column, '2', '' );
    UPDATE table SET column = replace(column, '3', '' );
    UPDATE table SET column = replace(column, '4', '' );
    UPDATE table SET column = replace(column, '5', '' );
    UPDATE table SET column = replace(column, '6', '' );
    UPDATE table SET column = replace(column, '7', '' );
    UPDATE table SET column = replace(column, '8', '' );
    UPDATE table SET column = replace(column, '9', '' );