char不是可变长的,如果你定义了char(1000),那么你即使在里面存放了1个字母,那么他所占的长度仍然是1000,其他的使用空格来填充
varchar2是一个可变长的,你存入多少她就有多长
char(size byte)和char(size char)举个例子来说吧,如果你定义了char(10 byte)和char(10 char),那么当你往这个字段存入数据的时候,前者只能存储5个汉字,而后者却能存储10个汉字,当然如果你仅仅存储的是英文字符,那就没有什么区别了nchar和nvarchar2就不知道有什么区别了,不过好像都属于淘汰的类型,一般来说都用varcahr2的

解决方案 »

  1.   

    谢谢你,但我的分很少,不好意思给你20吧,还有点好象不对,char (10 byte) char(10 char)存汉字都只能存5个!他两个的区别我还不清楚!
      

  2.   

    CHAR Datatype
    The CHAR datatype specifies a fixed-length character string. Oracle subsequently ensures that all values stored in that column have the length specified by size. If you insert a value that is shorter than the column length, then Oracle blank-pads the value to column length. If you try to insert a value that is too long for the column, then Oracle returns an error.The default length for a CHAR column is 1 byte and the maximum allowed is 2000 bytes. A 1-byte string can be inserted into a CHAR(10) column, but the string is blank-padded to 10 bytes before it is stored.When you create a table with a CHAR column, by default you supply the column length in bytes. The BYTE qualifier is the same as the default. If you use the CHAR qualifier, for example CHAR(10 CHAR), then you supply the column length in characters. A character is technically a codepoint of the database character set. Its size can range from 1 byte to 4 bytes, depending on the database character set. The BYTE and CHAR qualifiers override the semantics specified by the NLS_LENGTH_SEMANTICS parameter, which has a default of byte semantics.
    --------------------------------------------------------------------------------
    Note: 
    To ensure proper data conversion between databases with different character sets, you must ensure that CHAR data consists of well-formed strings. See Oracle9i Database Globalization Support Guide for more information on character set support.--------------------------------------------------------------------------------
     See Also: 
    "Datatype Comparison Rules" for information on comparison semantics
     NCHAR Datatype
    Beginning with Oracle9i, the NCHAR datatype is redefined to be a Unicode-only datatype. When you create a table with an NCHAR column, you define the column length in characters. You define the national character set when you create your database.The column's maximum length is determined by the national character set definition. Width specifications of character datatype NCHAR refer to the number of characters. The maximum column size allowed is 2000 bytes.If you insert a value that is shorter than the column length, then Oracle blank-pads the value to column length. You cannot insert a CHAR value into an NCHAR column, nor can you insert an NCHAR value into a CHAR column.The following example compares the col1 column of tab1 with national character set string 'NCHAR literal':SELECT translated_description from product_descriptions
       WHERE translated_name = N'LCD Monitor 11/PM';See Also: 
    Oracle9i Database Globalization Support Guide for information on Unicode datatype support
     NVARCHAR2 Datatype
    Beginning with Oracle9i, the NVARCHAR2 datatype is redefined to be a Unicode-only datatype. When you create a table with an NVARCHAR2 column, you supply the maximum number of characters it can hold. Oracle subsequently stores each value in the column exactly as you specify it, provided the value does not exceed the column's maximum length.The column's maximum length is determined by the national character set definition. Width specifications of character datatype NVARCHAR2 refer to the number of characters. The maximum column size allowed is 4000 bytes.See Also: 
    Oracle9i Database Globalization Support Guide for information on Unicode datatype support
     VARCHAR2 Datatype
    The VARCHAR2 datatype 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 column's maximum length. 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 codepoint of the database character set. CHAR and BYTE qualifiers override the setting of the NLS_LENGTH_SEMANTICS parameter, which has a default of bytes. The maximum length of VARCHAR2 data is 4000 bytes. Oracle compares VARCHAR2 values using nonpadded comparison semantics.
    --------------------------------------------------------------------------------
    Note: 
    To ensure proper data conversion between databases with different character sets, you must ensure that VARCHAR2 data consists of well-formed strings. See Oracle9i Database Globalization Support Guide for more information on character set support.--------------------------------------------------------------------------------
     See Also: 
    "Datatype Comparison Rules" for information on comparison semantics
     VARCHAR Datatype
    The VARCHAR datatype is currently synonymous with the VARCHAR2 datatype. Oracle recommends that you use VARCHAR2 rather than VARCHAR. In the future, VARCHAR might be defined as a separate datatype used for variable-length character strings compared with different comparison semantics.
      

  3.   

    char(size byte)是以字节来计算的,汉字占用几个字节存储是和db的character set有关的,可能是1到4个,所以char(10 byte)不一定就能存5个汉字;char(size char)就可以