Permission required: System administrator.
The convtouni utility converts character data in a database to Unicode, which lets you conveniently transform data in local encoding to Unicode. The utility converts all columns of data type char to nchar, and data type varchar to nvarchar.
Note: Convtouni should be run on a database that has Unicode support enabled. To enable Unicode support on a non-Unicode database, run alterdb with the –n option. For details, see alterdb Command.
This utility creates an intermediate SQL script that contains appropriate alter table statements to be executed, and an execution script for executing the SQL commands on the database. This two-step process allows you to examine the SQL script.
To complete the conversion process, execute the execution script after running the convtouni utility. In automodify mode, the execution script is created in a temporary directory and executed immediately.
By default, all columns of all tables that have char or varchar columns are altered and modified. If you specify a table list then only those tables are altered if they have char or varchar columns.
The convtouni command has the following format:
convtouni dbname [-param_file=filename] | [[-uuser] [-P] [-Ggroupid] [-dest=dir]
[-sqlfile=filename] [-automodify] [-col=column [-col=column]...] [{tables ...}]]
Specifies the name of the database to be exported.
Specifies the command file that contains the options to the convtouni command. If used, do not specify other options on the convtouni command. The file must contain all options and each parameter (dbname, table, user, and so on) must be on a separate line.
Specifies the effective user for the session.
Specifies the password if the session requires one.
Specifies the group ID of the user.
Specifies the directory the output SQL file will be written to.
Specifies the name of the output SQL file.
Modifies the tables immediately.
Specifies the column to convert, in tablename.columnname format. Each column must be preceded by –col=. Only the specified columns are changed; the rest of the char and varchar columns remain unchanged.
Note: No more than 100 objects can be specified. This limit can be raised by modifying the utexe.def file. For more information, see the Database Administrator Guide.
Specifies a list of tables to convert. If no list is specified, but the col= option is, then all specified columns of all tables owned by the user are altered. However, for the tables specified on the –col= option, only the specified columns are converted to Unicode.
Note: No more than 100 objects can be specified. This limit can be raised by modifying the utexe.def file. For more information, see the Database Administrator Guide.
Given a database userdb with tables tab1, tab2, tab3, and tab4 with char and varchar columns, the following command creates statements to convert all columns of all tables to Unicode.
convtouni userdb
On UNIX, this command generates SQL script ctouout.sql and an executable script ctouexec.ing.
The following command on UNIX converts three columns in the tab1 table and all columns of tab2 table of the userdb database into Unicode. The sqlfile=myfile.sql and the executable script ctouexec.ing is generated in directory /users/ingres/myloc:
convtouni userdb -dest=/users/ingres/myloc sqlfile=myfile.sql -col=tab1.col1
-col=tab1.col2 col=tab1.col3 tab2
The following command immediately executes the above commands:
convtouni userdb -automodify -col=tab1.col1 –col=tab1.col2 –col=tab1.col3 tab2
The following command converts all columns of all tables, but only col1 and col2 of the tab1 table:
convtouni userdb –automodify –col=tab1.col1 –col=tab1.col2