?
Solved

Difference between ALL_TAB_COLUMNS: DATA_LENGTH and CHAR_LENGTH

Posted on 2006-11-04
5
Medium Priority
?
6,218 Views
Last Modified: 2012-05-05
What is the difference between the DATA_LENGTH column and the CHAR_LENGTH column of the data dictionary
ALL_TAB_COLUMNS? ?

0
Comment
Question by:aman_greval
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 35

Expert Comment

by:Raynard7
ID: 17875153
Hi,

most of the time they are going to be the same,

Data_Length is the length of the column in bytes - Char_Length is the length of the column in characters.

Both will not necessarily be poplulated,

please refer to the official documentation (have used 10g here) for the meaning of everything in this data dictionary
http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14237/statviews_2094.htm#sthref1695
0
 
LVL 6

Accepted Solution

by:
DLyall earned 1000 total points
ID: 17876007
For example, a column type of VARCHAR(20) wiil have a character_length of 20 and a data_length of 20.
A column of type NUMBER will have a data_length of 22 but no character_length value.
A column of type ROWID will have a data_length 10 but no character_length.

It depends on the column type.
0
 
LVL 48

Expert Comment

by:schwertner
ID: 17880626
using Unicode a character may reside in more then 1 byte (by AL32UTF8 - up to 4 bytes).
There are two possibilities to define an VARCHAR2 column:

name VARCHAR2(20 byte);
name VARCHAR2(20 char);

The first is measured in bytes. It can not be longer then 20 bytes
The second is measured in characters - it can be long up to 8 bytes:  20 characters every 4 bytes ---->  80 bytes.
So it depends how you define the field.
0
 
LVL 35

Expert Comment

by:Raynard7
ID: 17943605
how was my decision (Raynard7) and that of schwertner wrong?
0
 

Author Comment

by:aman_greval
ID: 17944642
Dyall example made the concept very clear to me even on first reading.
Your examples were not wrong.
At the end i suppose, the simple and clear example made all the difference.

For example, a column type of VARCHAR(20) wiil have a character_length of 20 and a data_length of 20.
A column of type NUMBER will have a data_length of 22 but no character_length value.
A column of type ROWID will have a data_length 10 but no character_length.

It depends on the column type.

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question