Tuesday, June 14, 2022

Oracle SQL CHAR Data Type

1.It is used to store fixed length values.
2.By default, the size is 1 character, and max size is 2000 chars or bytes.
3.you need to specify a string length either in bytes or characters CHAR(size BYTE),CHAR(size CHAR).
4. If you don’t specify BYTE or CHAR followed the length, Oracle uses the BYTE by default.
 

Example Blank Space usage:

create table test(name char(20),ename varchar2(20));

insert into test values('Welcome', 'Welcome1');

Select * from test;

 



Name CHAR(20)  

If value Welcomeis inserted into the column then (even it is a 7 character string) system will consider it as 20 character string with 13 spaces after the last character. i.e. ‘Welcome
Using this char data type will have performance issues as it is fixed length and will assign unnecessary space if short

  To overcome this Oracle has introduced another data type called ‘varchar/varchar2’  

No comments:

Post a Comment