Unix Technical Forum

how to increase char(35) to char(100)

This is a discussion on how to increase char(35) to char(100) within the DB2 forums, part of the Database Server Software category; --> Hi All: In the table XYZ.ORD_DTL the column PDT_DESC is CHAR(35). I want to increase it to CHAR(100). However, ...


Go Back   Unix Technical Forum > Database Server Software > DB2

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 07:35 AM
ipy2006
 
Posts: n/a
Default how to increase char(35) to char(100)

Hi All:
In the table XYZ.ORD_DTL the column PDT_DESC is CHAR(35). I want to
increase it to CHAR(100). However, I am getting the following error.
Please help!

db2 => alter table XYZ.ORD_DTL alter column PDT_DESC SET DATA TYPE
CHAR(100)

DB21034E The command was processed as an SQL statement because it was
not a
valid Command Line Processor command. During SQL processing it
returned:
SQL0190N ALTER TABLE "OMS.ORD_DTL" specified attributes for column
"PDT_DESC"
that are not compatible with the existing column. SQLSTATE=42837

Thanks

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 07:35 AM
Gregor =?UTF-8?B?S292YcSN?=
 
Posts: n/a
Default Re: how to increase char(35) to char(100)

ipy2006 wrote:

> Hi All:
> In the table XYZ.ORD_DTL the column PDT_DESC is CHAR(35). I want to
> increase it to CHAR(100). However, I am getting the following error.
> Please help!
>
> db2 => alter table XYZ.ORD_DTL alter column PDT_DESC SET DATA TYPE
> CHAR(100)
>
> DB21034E The command was processed as an SQL statement because it was
> not a
> valid Command Line Processor command. During SQL processing it
> returned:
> SQL0190N ALTER TABLE "OMS.ORD_DTL" specified attributes for column
> "PDT_DESC"
> that are not compatible with the existing column. SQLSTATE=42837
>
> Thanks


You can only change VARCHAR data type directly with ALTER TABLE, but you can
do this:
CREATE TABLE TMP_ORD_DTL LIKE OMS.ORD_DTL;
INSERT INTO TMP_ORD_DTL SELECT * FROM OMS.ORD_DTL;
DROP TABLE OMS.ORD_DTL;
CREATE TABLE OMS.ORD_DTL
(
COLUMN1 CHAR(100),
.....
);
INSERT INTO OMS.ORD_DTL SELECT * FROM TMP_ORD_DTL;
DROP TABLE TMP_ORD_DTL;

Best regards,
Kovi
--
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
| Gregor Kovac | Gregor.Kovac@mikropis.si |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-27-2008, 07:35 AM
Shashi Mannepalli
 
Posts: n/a
Default Re: how to increase char(35) to char(100)

You cannot do it for CHAR column.

You can modify the characteristics of a column by increasing the length
of an existing VARCHAR or VARGRAPHIC 2 column. 2 The number of
characters may increase up to a value dependent on the page size used.

export/drop/re-create/load is one option.

Shashi Mannepalli



ipy2006 wrote:
> Hi All:
> In the table XYZ.ORD_DTL the column PDT_DESC is CHAR(35). I want to
> increase it to CHAR(100). However, I am getting the following error.
> Please help!
>
> db2 => alter table XYZ.ORD_DTL alter column PDT_DESC SET DATA TYPE
> CHAR(100)
>
> DB21034E The command was processed as an SQL statement because it was
> not a
> valid Command Line Processor command. During SQL processing it
> returned:
> SQL0190N ALTER TABLE "OMS.ORD_DTL" specified attributes for column
> "PDT_DESC"
> that are not compatible with the existing column. SQLSTATE=42837
>
> Thanks


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-27-2008, 07:35 AM
Serge Rielau
 
Posts: n/a
Default Re: how to increase char(35) to char(100)

Shashi Mannepalli wrote:
> You cannot do it for CHAR column.

Note, this is supported in DB2 9.

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-27-2008, 07:35 AM
Shashi Mannepalli
 
Posts: n/a
Default Re: how to increase char(35) to char(100)

Thanks Serge.



Serge Rielau wrote:
> Shashi Mannepalli wrote:
> > You cannot do it for CHAR column.

> Note, this is supported in DB2 9.
>
> Cheers
> Serge
>
> --
> Serge Rielau
> DB2 Solutions Development
> IBM Toronto Lab
>
> IOD Conference
> http://www.ibm.com/software/data/ond...ness/conf2006/


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-27-2008, 07:36 AM
Gregor =?UTF-8?B?S292YcSN?=
 
Posts: n/a
Default Re: how to increase char(35) to char(100)

Serge Rielau wrote:

> Shashi Mannepalli wrote:
>> You cannot do it for CHAR column.

> Note, this is supported in DB2 9.
>
> Cheers
> Serge
>


Yes and other data types too
I've converted a table with millions of rows from DECIMAL(18,2) to
DECIMAL(31, 15) in matter of minutes.

Best regards,
Kovi
--
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
| Gregor Kovac | Gregor.Kovac@mikropis.si |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:27 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com