我试图在oracle表中增加一列,其id定义为raw:
ID VALUE
----------
1 A14
2 B13
3 C15
4 D16
我需要
ID VALUE
----------
1 A24
2 B23
3 C25
4 D26
oracle中有任何函数如何递增? 感谢
答案 0 :(得分:2)
使用格式为掩码TO_NUMBER
的{{1}}和TO_CHAR
作为十六进制数字:
Oracle 11g R2架构设置:
X
查询1 :
CREATE TABLE TABLE_NAME (
ID INTEGER,
VALUE VARCHAR2(20)
);
INSERT INTO TABLE_NAME
SELECT 1, 'A14' FROM DUAL UNION ALL
SELECT 2, 'B13' FROM DUAL UNION ALL
SELECT 3, 'C15' FROM DUAL UNION ALL
SELECT 4, 'D16' FROM DUAL UNION ALL
SELECT 5, 'FFF' FROM DUAL;
UPDATE table_name
SET value = TO_CHAR( TO_NUMBER( value, 'XXXX' ) + TO_NUMBER( '10', 'XX' ), 'FMXXXX' );
<强> Results 强>:
SELECT * FROM table_name