How to get the min and max varchar field size in DB2 table?

RDBMS from IBM and IBM's Hierarchical DBMS and Transaction Manager (IMS DC).
Post Reply
LalitaForums
New Member
Posts: 8
Joined: Thu Jul 31, 2014 11:33 am

How to get the min and max varchar field size in DB2 table?

Post by LalitaForums »

Hi All,

I have a VARCHAR column in a DB2 table. I'm trying to know the minimum and maximum size this varchar filed can store. I tried using the MIN and MAX function but they can only be used for the numeric data type. Is there any function with which I can find the length for varchar, please help.
User avatar
Anuj Dhawan
Founder
Posts: 2801
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: How to get the min and max varchar field size in DB2 tab

Post by Anuj Dhawan »

Hi,

MIN/MAX should have worked for you, try this:

Code: Select all

SELECT  MIN(LENGTH(VARCHAR_COL_A)),MAX(LENGTH(VARCHAR_COL_A)) 
  FROM  TABLE_NAME
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
LalitaForums
New Member
Posts: 8
Joined: Thu Jul 31, 2014 11:33 am

Re: How to get the min and max varchar field size in DB2 tab

Post by LalitaForums »

Great thanks Anuj.
User avatar
Anuj Dhawan
Founder
Posts: 2801
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: How to get the min and max varchar field size in DB2 tab

Post by Anuj Dhawan »

You're welcome! :)
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM DB2 and IMS DB/DC”