Solved

Difference between ALL_TAB_COLUMNS: DATA_LENGTH and CHAR_LENGTH

Posted on 2006-11-04
5
5,686 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 250 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious sideā€¦
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

749 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