Char Varchar Viswam

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

Data types:

============================
defintion:
------------
data type sprcfies type of data within table column
oracle having following datatypes they are
1)number
2)number(p,s)
3)char
4)varchar
5)varchar2
6)blob
7)raw
8)long raw
9)timestamp
10)date

char:
==========
-->it is used to store fixed length alphanumberic data in bytes

name
123
batch1
kappp@33

eg-
state
ap
dl

country
ind
usa

-->in oracle whenever we are using char datatype and also when use are try to store
less no the bytes then maximum size is char datatype then oracle sever internally
automatically add blanks spaces in place of remaning bytes at the end of he string
this is called blank padded mechanisum.

states codes
=========================
ap
tn
dl
country code
=====================
india-ind
america-usa
rissa-rsa

syntax:
================
columnname char(size)
maximum size is of the char datatype is upto 2000 bytes

select dump(name) from test12;

Typ=96 Len=4: 104,97,114,105


Typ=96 Len=4: 106,97,105,32
Typ=96 Len=4: 104,97,114,105
Typ=96 Len=4: 106,97,105,32

note:
===========
in oracle by default char datatype having one byte

create table test12(name char(4));

insert into test12 values('hari');


insert into test12 values('pavani');
insert into test12 values('jai');

varchar2:
-------------------
-->it is used to store varable length alphanumberic data in bytes

oracle 7.0 introduced varchar2

if you try to store less no of the bytes remaining bytes oracle does'nt add blank
spaces that why
whatever data we are inserting that data only memory are reseverd

syntax:
--------------
columnname varchar2(size)
maximum size of the varcahr2 datatype is upto 4000 bytes

alphanumberic ---Aa@%&&*1234
%&*----special charcter
A
a
123

create table test13(name varchar2(4));


insert into test13 values('hari');
insert into test13 values('jai');
select* from test13;

varchar2:
======================

select dump(name) from test13;

Typ=1 Len=4: 104,97,114,105


Typ=1 Len=3: 106,97,105
varchar(size)
===================================
-v2.0,3.0,4.0,5.0,6.0,6.1 upto these version only varchar datatype is there after
that use varchar2

---> oracle 7.0 if we want to store variable length alpha-numberic data then we are
using varchar datatype

syntax:
=========
column name varchar(size)

test
========
create table test(name varchar(10));

desc test;

type
======
varchar2(10)

Note:
==========
in oracle 7.0 onwards whenever we are using creating varchar datatype also then
oracle server internally automatically converts varchar datatype into varchar2
datatype.

varchar is upto 2000 bytes


varchar2 is upto 4000 bytes

difference b/w varchar,varchar2 datatype


=================================================
varchar datatype is an Ansi(american national standard)standard datatype which
works with all releational databases and also this datatype stores upto 2000 bytes
whereas varchar2 datatype is an oracle standard and also varchar2 datatype stores
upto 4000 bytes

--->varchar and varchar2 memory management same(disc space never wasted)

================

You might also like