Oracle VARCHAR2 Data Type

1.     Used to store variable length character values.

2.     No default size. VARCHAR2 column can store a value that ranges from 1 to 4000 bytes.

3.   When you create a table with a VARCHAR2 column, you must specify the length size    bytes or characters.                  

              VARCHAR2(size BYTE)

              VARCHAR2(size CHAR)

 4.   By default, Oracle uses BYTE if you don’t specify BYTE or CHAR after the size otherwise VARCHAR2(10) column can hold up to 10 bytes of characters.

          For example

1.    if you define a VARCHAR2 column with a maximum size is 20. In a single-byte character set, you can store up to 20 characters. If you store 21 characters or more, Oracle returns an error.

2.    In addition, if you store 10 characters in a VARCHAR2(20) column, Oracle uses only 10 bytes for storage, not 20 bytes. Therefore, using VARCHAR2 data type helps you save spaces used by the table.

           VARCHAR2 Maximum Length

  You must specify size for VARCHAR2. Minimum size is 1 byte or 1 character. Maximum size is:

  •   32767 bytes or characters if MAX_STRING_SIZE = EXTENDED
  •  4000 bytes or characters if MAX_STRING_SIZE = STANDARD

 

Ex:   
ename   varchar2(20)
---------   --------------------
Dileep
Kumar
Kalyan
Dileep Kumar
ram

No comments:

Post a Comment