删除在字符串列中找到的数字

Remove numbers found in string column

使用 Sqlite 删除在其他字符串列中找到的所有数字的 SQL 是什么(Oracle 示例也将不胜感激)?

示例:我想从这样的条目中删除所有数字:

291 HELP,1456 CALL

预期输出:

HELP,CALL

编辑:我已经编辑了这个问题,因为我不仅要从一个条目中删除数字,而且要删除其中的许多数字。

select '''' || regexp_replace('123 help 321', '\d+') || '''' from dual;

要么你用语言来做,你嵌入 sqlite,要么你使用这个 SQLite 代码,删除所有数字:

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', '' );

使用 TRANSLATEREPLACE

SQL> WITH DATA AS(
  2  SELECT '291 HELP' str FROM dual UNION ALL
  3  SELECT '1456 CALL' str FROM dual
  4  )
  5  SELECT REPLACE(translate(str, '0123456789', ' '), ' ', NULL) str
  6  FROM DATA
  7  /

STR
---------
HELP
CALL

SQL>

使用REGEXP_REPLACE

SQL> WITH DATA AS(
  2  SELECT '291 HELP' str FROM dual UNION ALL
  3  SELECT '1456 CALL' str FROM dual
  4  )
  5  SELECT trim(regexp_replace(str, '[0-9]+')) str
  6  FROM DATA
  7  /

STR
---------
HELP
CALL

SQL>

POSIX字符class

SQL> WITH DATA AS(
  2  SELECT '291 HELP' str FROM dual UNION ALL
  3  SELECT '1456 CALL' str FROM dual
  4  )
  5  SELECT trim(regexp_replace(str, '^[[:digit:]]+')) str
  6  FROM DATA
  7  /

STR
---------
HELP
CALL

SQL>

Perl 扩展

SQL> WITH DATA AS(
  2  SELECT '291 HELP' str FROM dual UNION ALL
  3  SELECT '1456 CALL' str FROM dual
  4  )
  5  SELECT trim(regexp_replace(str, '\d+')) str
  6  FROM DATA
  7  /

STR
---------
HELP
CALL

SQL>