面试的时候有考官问说varchar2(2000)和varchar2(1999)有和不同,我不明白
请教一下

解决方案 »

  1.   

    对于VARCHAR2(长度>=2000)变量,PL/SQL动态分配内存来存放实际值,但对于VARCHAR2(长度<2000)变量,PL/SQL会预先分配足够的内存。
    所以,如果我们把同样一个500字节的值放入一个VARCHAR2(2000)和一个 VARCHAR2(1999)变量中,后者会多占用1499个字节的内存
      

  2.   

    确实是不同 正如fenyun61说的
      

  3.   


     ding j ding    
      

  4.   

    Small   VARCHAR2   variables   are   optimized   for   performance,   and   larger   ones   are   optimized   for   efficient   memory   use.   The   cutoff   point   is   2000   bytes.   For   a   VARCHAR2   that   is   2000   bytes   or   longer,   PL/SQL   dynamically   allocates   only   enough   memory   to   hold   the   actual   value.   For   a   VARCHAR2   variable   that   is   shorter   than   2000   bytes,   PL/SQL   preallocates   the   full   declared   length   of   the   variable.   For   example,   if   you   assign   the   same   500-byte   value   to   a   VARCHAR2(2000   BYTE)   variable   and   to   a   VARCHAR2(1999   BYTE)   variable,   the   former   takes   up   500   bytes   and   the   latter   takes   up   1999   bytes