ORACLE数据库报错ORA-00910: specified length too long for its datatype

ORACLE数据库报错ORA-00910: specified length too long for its datatype

原因分析

先直接说下对于ORA-00910报错的原因:在于Oracle数据库中VARCHAR2最大存储4000字节长度的数据

关于Oracle中VARCHAR2详细说明

根据官方说明,在Oracle数据库中VARCHAR2类型字段可声明为byte或char,如:varchar2(100)[ varchar2(100 byte) ] - 100字节长度、varchar2(100 char) - 100字符长度,但无论是哪种,最大只能是4000字节,VARCHAR2字段类型的详细说明可参数下述内容,其他类型说明请查看官方说明

官方说明:Database SQL Language Reference

{ CHAR [ (size [ BYTE | CHAR ]) ]
| VARCHAR2 (size [ BYTE | CHAR ])
| NCHAR [ (size) ]
| NVARCHAR2 (size)
}

ORACLE数据库报错ORA-00910: specified length too long for its datatype_第1张图片

Data Type Description
VARCHAR2(size [BYTE ]|[CHAR]) Variable-length character string having maximum length size bytes or characters. Maximum size is 4000 bytes or characters, and minimum is 1 byte or 1 character. You must specify size for VARCHAR2.BYTE indicates that the column will have byte length semantics. CHAR indicates that the column will have character semantics.

VARCHAR2 Data Type

The VARCHAR2 data type specifies a variable-length character string. When you create a VARCHAR2 column, you supply the maximum number of bytes or characters of data that it can hold. Oracle subsequently stores each value in the column exactly as you specify it, provided the value does not exceed the maximum length of the column. If you try to insert a value that exceeds the specified length, then Oracle returns an error.

You must specify a maximum length for a VARCHAR2 column. This maximum must be at least 1 byte, although the actual string stored is permitted to be a zero-length string (''). You can use the CHAR qualifier, for example VARCHAR2(10 CHAR), to give the maximum length in characters instead of bytes. A character is technically a code point of the database character set. You can use the BYTE qualifier, for example VARCHAR2(10 BYTE), to explicitly give the maximum length in bytes. If no explicit qualifier is included in a column or attribute definition when a database object with this column or attribute is created, then the length semantics are determined by the value of the NLS_LENGTH_SEMANTICS parameter of the session creating the object. Independently of the maximum length in characters, the length of VARCHAR2 data cannot exceed 4000 bytes. Oracle compares VARCHAR2 values using nonpadded comparison semantics.

你可能感兴趣的:(#,Oracle,数据库,oracle,ora-00910,varchar2)