1、装Oracle时选的字符集是什么?有些字符集是用多个字节(byte)存储一个汉字的。
2、字符串中会不会有某种乱码,显示不出但占空间。
3, select lengthb('你输入的字') from dual 看下占多少字节

解决方案 »

  1.   

    看pl/sql user's guide,或者查我回复的帖子,你会有答案的
      

  2.   

    VARCHAR2You use the VARCHAR2 datatype to store variable-length character data. How the data is represented internally depends on the database character set. The VARCHAR2 datatype takes a required parameter that specifies a maximum size up to 32767 bytes. The syntax follows:VARCHAR2(maximum_size [CHAR | BYTE])You cannot use a symbolic constant or variable to specify the maximum size; you must use an integer literal in the range 1 .. 32767.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.If you specify the maximum size in bytes rather than characters, a VARCHAR2(n) variable might be too small to hold n multibyte characters. To avoid this possibility, use the notation VARCHAR2(n CHAR)so that the variable can hold n characters in the database character set, even if some of those characters contain multiple bytes. When you specify the length in characters, the upper limit is still 32767 bytes. So for double-byte and multibyte character sets, you can only specify 1/2 or 1/3 as many characters as with a single-byte character set.Although PL/SQL character variables can be relatively long, the maximum width of a VARCHAR2 database column is 4000 bytes. So, you cannot insert VARCHAR2 values longer than 4000 bytes into a VARCHAR2 database column.You can insert any VARCHAR2(n) value into a LONG database column because the maximum width of a LONG column is 2**31 bytes. However, you cannot retrieve a value longer than 32767 bytes from a LONG column into a VARCHAR2(n) variable.When you do not use the CHAR or BYTE qualifiers, the default is determined by the setting of the NLS_LENGTH_SEMANTICS initialization parameter. When a PL/SQL procedure is compiled, the setting of this parameter is recorded, so that the same setting is used when the procedure is recompiled after being invalidated.
      

  3.   

    和字符集有关吧。
    Oracle是4000字节
      

  4.   

    在PL/SQL中,字符最多能定义32767字节,太大的话不行.但实际写的时候,PL/SQL语句中写多少,也有限制. 如果你的字符较多,建议使用CLOB类型的,4G大小,够用了.