首页 > 其他 > 详细

insert into varchar2(8000)

时间:2014-03-13 03:11:32      阅读:555      评论:0      收藏:0      [点我收藏+]

在看12c的文档的时候发现varcahr2最大长度是4000 byte

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.

To ensure proper data conversion between databases with different character sets, you must ensure that VARCHAR2 data consists of well-formed strings. SeeOracle Database Globalization Support Guide for more information on character set support.

 

但是下面的SQL可以把8000长度的字符串insert到varchar2中。 为什么呢?

bubuko.com,布布扣
declare
    v1 varchar2(8000);
begin
    v1 := a;
    for i in 1..7900 loop
        v1 := v1||a;
    end loop;
    --dbms_output.put_line(v1);
    insert into t values(v1);
end;
bubuko.com,布布扣

insert into varchar2(8000),布布扣,bubuko.com

insert into varchar2(8000)

原文:http://www.cnblogs.com/kramer/p/3596867.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!