Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to retreive the max data length of a column

505001Aug 3 2006 — edited Aug 4 2006
Hello All,

I know how to do a select to get the max data length of a column it is this :

SELECT MAX(LENGTH(COLUMN_NAME) FROM table.

However, I need this information combined with my SQL that returns the Data_type and length from the USER_TAB_COLUMNS. So taking the emp example if the ename column was 50 as VARCHAR2 but the max data entered in it was just 20 I want the information like this:

SELECT COLUMN_NAME, DATA_LENGTH, and the Max length of 20
FROM USER_TAB_COLUMNS WHERE TABLE_NAME='EMP';

I don't know how to get the Max Length of the Column in this table. Can anyone suggest me a hint? An Inline view maybe?

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 1 2006
Added on Aug 3 2006
8 comments
15,753 views