Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: How do I change the length of a primary key in a table
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Loading data to table gives wrong for... Raghu navaikulam DB2 19 Thu Jul 13, 2017 2:11 pm
No new posts How to change 'K' or 'M' use Sort vice_versa DFSORT/ICETOOL 5 Thu May 18, 2017 7:11 am
No new posts unload data from table with lob columns farhad_evan DB2 1 Sat Apr 22, 2017 1:32 pm
No new posts Length of Tape file Mohan Kothakota JCL & VSAM 9 Thu Apr 20, 2017 10:24 pm
No new posts Sort Large record length cmsmoon DFSORT/ICETOOL 14 Tue Apr 11, 2017 5:49 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us