IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How do I change the length of a primary key in a table


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
jayanta_nit

New User


Joined: 13 Apr 2006
Posts: 22
Location: hyderabad

PostPosted: Tue Apr 10, 2007 12:52 pm
Reply with quote

Hi,
How do I change the length of a primary key in a table?

Thanks
Jayanta
Hyderabad
Back to top
View user's profile Send private message
ragganga

New User


Joined: 22 Jan 2007
Posts: 18
Location: bangalore

PostPosted: Tue Apr 10, 2007 1:31 pm
Reply with quote

Hi Jayanth,

As per my knowledge, we can not change lenght of any column in DB2 Table.

Solution is, Create another Table with same features of that Table with increasing primary column length.

If i am wrong, please correct me.

Regards
Raghu.
Back to top
View user's profile Send private message
divya_maddi

New User


Joined: 03 Nov 2005
Posts: 33

PostPosted: Tue Apr 10, 2007 2:58 pm
Reply with quote

the length of varying-length character data type values allowed for a particular column can be increased by executing the ALTER TABLE SQL statement

So if your primary key is defined as varchar, you can change its length with the following syntax:

ALTER COLUMN [ColumnName] SET DATA TYPE [VARCHAR | CHARACTER VARYING | CHAR VARYING] ([Length])

Example:

ALTER COLUMN DEPTNAME SET DATA TYPE VARCHAR(100)

The above statement will set the maximum length of deptname column to 100 bytes.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Store the data for fixed length COBOL Programming 1
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top