Oracle将字符插入字符串 [英] Oracle insert character into a string

查看:671
本文介绍了Oracle将字符插入字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有此行表

RowA
______
ABC123
DEF432
WER677
JKL342

如何在使用oracle的记录之间添加一个"_"? 假设要添加最后4个字符.

how can I add a '_' in between the record using oracle to this? Assuming to add on the last 4 character.

RowA
______
ABC_123
DEF_432
WER_677
JKL_342

推荐答案

您可以尝试以下方法:

Update Table_name set table_column = substr(table_column, 1, 3) || '_' || substr(table_column, 4);

SUBSTR函数允许您从字符串中提取子字符串. SUBSTR函数的语法为:

The SUBSTR functions allows you to extract a substring from a string. The syntax for the SUBSTR function is:

SUBSTR( string, start_position, [ length ] )

string是源字符串.

start_position是提取位置.字符串中的第一个位置始终为1.

start_position is the position for extraction. The first position in the string is always 1.

length是可选的.它是要提取的字符数.如果省略此参数,则SUBSTR函数将返回整个字符串.

length is optional. It is the number of characters to extract. If this parameter is omitted, the SUBSTR function will return the entire string.

这篇关于Oracle将字符插入字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆