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

Difference between VARCHAR and CHAR


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

New User


Joined: 20 Jul 2008
Posts: 19
Location: Schenactady, US

PostPosted: Wed Sep 24, 2008 12:14 pm
Reply with quote

Hi,

We know that VARCHAR is a variable char and CHAR is a fixed char. If I declare CHAR(50) then 50 bytes will be allocated and used.
If I declare VARCHAR(50) and I'm giving the length as 10. Then only 10 bytes will be allocated and used.

Please correct me if i'm wrong.

Thanks,
Vel
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Sep 24, 2008 2:06 pm
Reply with quote

according to the documentation, your interpretation is correct.
Back to top
View user's profile Send private message
Bill Dennis

Active Member


Joined: 17 Aug 2007
Posts: 562
Location: Iowa, USA

PostPosted: Wed Sep 24, 2008 7:01 pm
Reply with quote

VARCHAR does use two extra bytes to indicate the actual length, so 12 bytes would be used.
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 SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Exclude rows with > than x occurre... DFSORT/ICETOOL 6
No new posts Timestamp difference and its average ... DB2 11
No new posts Difference when accessing dataset in ... JCL & VSAM 7
No new posts What is the difference between Taskty... Compuware & Other Tools 2
Search our Forums:

Back to Top