2

主题:数据清理 - 检查异常值 - 不正常

我正在尝试将 custID 从值“A123”更新为“123”,将“22A4”更新为“224”我只想将整数保留在 custID 中,我不希望 custID 包含任何非整数字符(A 到 Z 和a 到 z)

CREATE TABLE customer (
custID VARCHAR2(10) PRIMARY KEY,
custName VARCHAR2(30)
);
INSERT INTO customer(custID,custName) VALUES ('A123','Angel');
INSERT INTO customer(custID,custName) VALUES ('22A4','Chris');
INSERT INTO customer(custID,custName) VALUES ('2333','Chris');

UPDATE customer
SET custID =            -- I want to change 'A123' to '123', '22A4' to '224'
WHERE         ;
4

2 回答 2

2

用这个...

UPDATE customer
SET custID = REGEXP_REPLACE(custID, '[^0-9]+', '')
WHERE         ;

或试试这个...

UPDATE customer
SET custID = REGEXP_REPLACE(custID, '[^[:digit:]]+', '')
WHERE         ;
于 2013-05-04T15:55:42.827 回答
0

UPDATE customer SET custid = REGEXP_SUBSTR ( custid , '[0-9]*' ) WHERE

REGEXP_SUBSTR Oracle 文档

于 2013-05-04T17:02:52.043 回答