Oracle sqlldr data import error: Field in data file exceeds maximum length

When using oracle sqlldr to import data, a Field in data file exceeds maximum length error occurs: the
data length set in the ctl file is smaller than the actual data length.
For example: column char(2000) The actual data length exceeds 2000char
At this time, the length of the setting needs to be increased
The field length of the database is set to varchar2(2000 char) and also needs to be modified to varchar2(4000 char) at the same time

If the data length is not specified,
Oracle sqlldr defaults to VARCHAR(255) for this field

varchar2 (size type), the maximum size is 4000, the type can be char or byte, and the default is byte.

varchar2 stores up to 4000 bytes of data, regardless of whether the type is char or byte. So if you set varchar2(4000
char), you can store 4000 letters, but you cannot store 4000 Chinese characters. If the database character set encoding is GBK, then varchar2 can store up to 2000 Chinese characters, if the character set encoding is UTF-8, then it can only store up to 1333 Chinese characters.

nvarchar2 (size), the maximum size is 2000, the unit is characters, and whether it is Chinese characters or letters, the length of each character is 2 bytes. Therefore, nvarchar2 type data can store up to 2000 Chinese characters, and can only store up to 2000 letters. And nvarchar2 is different from varchar2, he is not affected by the database character set.

In addition, if we set both A1 and A2 to varchar2(4000), and the content length of these two fields exceeds 2000 bytes, then when using a
statement such as select A1||A2 from table, because the result exceeds 4000 characters section, so an error will be reported.

From the point of view of use, the difference is: NVARCHAR2 is related to the character set when calculating the length. For example, if the database is a Chinese character set, take the length 10 as an example, then

1. NVARCHAR2(10) can store 10 Chinese characters, if it is used to store English, it can only store 10 characters, and VARCHAR2(10), it can only store 5 Chinese characters, and English can store 10 characters
2. VARCHAR2 variable-length character field, the maximum length can reach 4000 characters, the variable-length character field of NVARCHAR2 multi-byte character set, the length depends on the character set, up to 2000 characters or 2000 bytes

1. If the characters in nvarchar are Chinese, they are generally calculated as 2 bytes, and English numbers are calculated as one by themselves. 2.
All characters in nvarchar2 are calculated as 2 bytes;
3. Although nvarchar2 takes up more space, it has better Compatibility (recommended);

Guess you like

Origin blog.csdn.net/Hx230/article/details/127103553