Search code examples
sqloraclesql-updatesql-types

UPDATE column with VARCHAR(2) 4000 byte value


I want to update a table with complex entries in a column and just a clause in the column without effecting other values.

Want to update #Rule number=0# to #Rule number=1# but without affecting other values in the column. Is this possible? enter image description here


Solution

  • Are you looking for replace()? If dynamic_attributes is a string:

    update t
        set dynamic_attributes = replace(dynamic_attributes,
                                         '#Rule number=0#',
                                         '#Rule number=1#'
                                         )
        where dynamic_attributes like '%#Rule number=0#%';
    

    Note: Strings may not be the best way to store such a list. You should consider a table with one row per customer_id and dynamic attribute.