By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,027 Members | 1,111 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,027 IT Pros & Developers. It's quick & easy.

Altering the type of a VARCHAR column to be VARCHAR FOR BIT DATA

P: n/a
Hi,

I'd like to know whether there is a way to alter the data type of a
VARCHAR FOR BIT DATA column to be simply a VARCHAR column? I executed
an ALTER TABLE statement, similar to,

ALTER TABLE tab_name ALTER COLUMN col_name SET DATA TYPE VARCHAR(100)

without any problems. However, a simple Java application reports via
JDBC that the column type is still VARCHAR FOR BIT DATA.

Secondly, how would I perform the opposite operation i.e. alter the
data type of a VARCHAR column to be VARCHAR FOR BIT DATA? A statement
such as the following fails:

ALTER TABLE tab_name ALTER COLUMN col_name SET DATA TYPE VARCHAR(100)
FOR BIT DATA

Please note that I'm looking for a solution that will be compatible
with DB2 v8 and v9.

Regards,

Ryan

May 28 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
RGow wrote:
Hi,

I'd like to know whether there is a way to alter the data type of a
VARCHAR FOR BIT DATA column to be simply a VARCHAR column? I executed
an ALTER TABLE statement, similar to,

ALTER TABLE tab_name ALTER COLUMN col_name SET DATA TYPE VARCHAR(100)

without any problems. However, a simple Java application reports via
JDBC that the column type is still VARCHAR FOR BIT DATA.

Secondly, how would I perform the opposite operation i.e. alter the
data type of a VARCHAR column to be VARCHAR FOR BIT DATA? A statement
such as the following fails:

ALTER TABLE tab_name ALTER COLUMN col_name SET DATA TYPE VARCHAR(100)
FOR BIT DATA

Please note that I'm looking for a solution that will be compatible
with DB2 v8 and v9.
If you want a DB2 V8.2 solution then I don't think there is a way around
unload an reload of the data. You can use the ALTOBJ() procedure or the
ALTER TABLE wizard in the control center to instrument the process.

Have you considered a view? A simple CAST(c1 AS VARCHAR(100) FOR SBCS
DATA) is all you need.

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
May 28 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.