Skip to Main Content
  • Questions
  • How can i incorporate a text to the existing values of a column

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Littymol.

Asked: October 28, 2016 - 5:51 am UTC

Last updated: October 28, 2016 - 8:38 am UTC

Version: 11g

Viewed 1000+ times

You Asked

Hi,

The query is as below,

I have a table in which i have the column named as V_QTN_NAME, here in this column the values are of different in each row. Now i am trying to differentiate the values by incorporating the text 'OLD'to the existing values. Can you please guide me how can i add the text OLD to the beginning of the column values in one shot.

Thank you in advance!

Litty.

and Chris said...

Just update the column for all rows, prepending 'OLD':

create table t (
  x varchar2(100)
);

insert into t
  select dbms_random.string('a', 10) from dual connect by level <= 10;

select * from t;

X           
rymGBKBuwd  
EKHxpzrDUy  
HIuhcZEATc  
kooiSDxcJx  
IRroyVLfpE  
TNVKETYrGU  
nmjlMXNEaz  
xAVMnGdGMR  
dYNonpIMZZ  
YkPtiUpEsY 

update t
set    x = 'OLD' || x;

select * from t;

X              
OLDrymGBKBuwd  
OLDEKHxpzrDUy  
OLDHIuhcZEATc  
OLDkooiSDxcJx  
OLDIRroyVLfpE  
OLDTNVKETYrGU  
OLDnmjlMXNEaz  
OLDxAVMnGdGMR  
OLDdYNonpIMZZ  
OLDYkPtiUpEsY 

Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Littymol Jacob, October 28, 2016 - 9:44 am UTC


More to Explore

DBMS_RANDOM

More on PL/SQL routine DBMS_RANDOM here