1

To handle few special characters, we changed string_units database configuration parameter from default SYSTEM to CODEUNITS32.

Based on IBM DB2 Knowledge Center, there are three methods to achieve this.

1.Set the NLS_STRING_UNITS global variable

2.Update the string_units database configuration parameter

  1. Alter the column by defining new character set ( CODEUNITS16 or CODEUNITS32)

We have used the second option and restarted the instance. Still it's not working as expected. Have we missed any steps?

Is the reorg required on the table? What happens to the already existing data ?

db2level - 10.5 fp5
OS : Windows

1 Answer 1

0
ALTER TABLE <schema>.<tabname> ALTER COLUMN <colname> SET DATA TYPE VARCHAR(20 CODEUNITS32);

The alter column set data type with CODEUNITS32 clause did the job. If the string_units database configuration parameter is set to CODEUNITS32, any new table without specifying this clause in column definition still works.

We have to perform the above alter only to the columns of existing table which was defined when string_units was set to default SYSTEM.

Hope it helps to other users.

1
  • The db cfg STRING_UNITS is how things should be interpreted if not declared explicitly. Since STRING_UNITS where SYSTEM when the table where created you will have to alter the table like you did if you would like it to be CODEUNITS32. You can check SYSCAT.COLUMNS.TYPESTRINGUNITS to find out what is used for a particular column. Also, if CODEUNITS32 is a special case and you normally use SYSTEM, you may want to change the db cfg to SYSTEM. Otherwise all new columns will become CODEUNITS32 unless you specify them as OCTET. Nov 1, 2020 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.