• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 6861
  • Last Modified:

Difference between ALL_TAB_COLUMNS: DATA_LENGTH and CHAR_LENGTH

What is the difference between the DATA_LENGTH column and the CHAR_LENGTH column of the data dictionary
ALL_TAB_COLUMNS? ?

0
aman_greval
Asked:
aman_greval
1 Solution
 
Raynard7Commented:
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
 
DLyallCommented:
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
 
schwertnerCommented:
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
 
Raynard7Commented:
how was my decision (Raynard7) and that of schwertner wrong?
0
 
aman_grevalAuthor Commented:
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now