Character Data Type In Oracle - Deepak YT

Character Data Type In Oracle 



Char: 

It is used to store fixed-length "alphanumeric" data in bytes. The maximum limit is up to 2000 bytes. 
                               
                                        Syntax. columnname char (size); 

By default, character datatype has one byte. Character datatype has automatically "Blank Padded". 

Blank Padded: 

Whenever we are passing less number of characters than the specified datatype size then oracle server 
automatically allocates blank spaces after the value. 

Varchar2 [max size] 

Oracle 7.0 introduced "varchar2()" datatype. It is used to store variable-length alphanumeric data in
bytes. Maximum limit is up to 4,O00 bytes.

Whenever we are using varchar2() datatype and also if we are try to store less no. of bytes then the
maximum size specifies within varchar2() datatype, then oracle server does not add blank spaces in
place of remaining bytes this is called variable-length alphanumeric data that's why here spa e were 
never wasted. 
                                    Syntax: columrname varchar2 (max size]; 


Varchar (Size]:

Prior to oracle 7.0 if you want to store variable length alpha numeric data then we are using varchar
data type. 
                                                      Syntax. columnname varchar {size); 

Here maximum size is up to 2000 bytes.

Oracle 7.0 onwards whenever we are creating a column with varchar datatype also then oracle server
internally automatically converts varchar data type into varchar2() datatype.

In varchar datatype also when we are trying to store less no. of bytes then the maximum size specified
varchar datatype then oracle server does not add blank spaces in place of remaining bytes. 

Difference between Varchar &Varchar2Data Types

Varchar datatype is ANSI standard datatype that's why it's with all relational database products but
Varchar() is an oracle standard_that's why this datatype works in oracle database only and also
varchar() datatypes stores upto 2000 bytes where as varchar2() datatypes stores up to 4000 bytes.

long:

in oracle if you want to store more than 4000 bytes of alpha numeric data then we are using long
datatypes. Long data types store up to 2 GB data. 

                                                            Syntax: columnname long; 

Generally here can be an only one long column for a table and also we are not allowed to create 
primary key for long datatype column. 
Example: 
                              SQL> create table test5 (column1 long, column2 long); 

Post a Comment

0 Comments