Solved

Difference between ALL_TAB_COLUMNS: DATA_LENGTH and CHAR_LENGTH

Posted on 2006-11-04
5
5,148 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
5 Comments
 
LVL 35

Expert Comment

by:Raynard7
Comment Utility
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 250 total points
Comment Utility
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 47

Expert Comment

by:schwertner
Comment Utility
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
Comment Utility
how was my decision (Raynard7) and that of schwertner wrong?
0
 

Author Comment

by:aman_greval
Comment Utility
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
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.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now