View previous topic :: View next topic
|
Author |
Message |
senthilkumarse Warnings : 1 New User
Joined: 16 Sep 2005 Posts: 7
|
|
|
|
hello sir/madam,
thank for ur valuable article o have send to me, now i am having another doubt in DB2 . in db2 we will creat etable like ( create table emp(empno char(5)) ) now i want to change thae attribute means i want to change char(5) to char (7) or varchar (5) ) what is the querruy to change the attributes plz clarify my doubts |
|
Back to top |
|
|
ikumar
New User
Joined: 02 Aug 2005 Posts: 81
|
|
|
|
ALTER COLUMN columnname SET DATATYPE VARCHAR (integer)
It Alters the definition of a column. Only the length attribute of an existing column with a VARCHAR data type can be changed. A column cannot be altered if it is used in a referential constraint or a view or has a field procedure routine. It also cannot be altered if it belongs to a table that has edit or validation routine, is defined with DATA CAPTURE CHANGES, or is a created temporary table.
check this link:
publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DSNSQH11/5.10?DT=20010718164132
So, in your case you cannot alter the column, as it is fixed, that is, CHAR.
If you really want to alter the table then you can take a back up of the table and drop the table and recreate it with new column definitions and load the table back with backup data.
Hope this helps...
Cheers,
Kumar. |
|
Back to top |
|
|
senthilkumarse Warnings : 1 New User
Joined: 16 Sep 2005 Posts: 7
|
|
|
|
thanks for ur valuable article
now i have one doubt what is AMP where we r using this in one interviem they asked to my friends he is not able to answer this so plz clear my doubt |
|
Back to top |
|
|
suganthyprabha
New User
Joined: 28 Jul 2005 Posts: 58
|
|
|
|
Hi Ikumar,
I am having doubt on this. Is it possible to change the Lenght of
Column in Mainframes?
Thanks and Regards,
Suganthy. |
|
Back to top |
|
|
senthilkumarse Warnings : 1 New User
Joined: 16 Sep 2005 Posts: 7
|
|
|
|
I am also having the same doubt on this, but i tried this i cant change it,
some others also replied the same thing for me that we cant change if u found out thae correct ans inform to me |
|
Back to top |
|
|
ikumar
New User
Joined: 02 Aug 2005 Posts: 81
|
|
|
|
Hi Suganthy,
we cannot change the length of the column in DB2 unless if it is a VARCHAR field (see my previous post on this). |
|
Back to top |
|
|
|