You are on page 1of 16

CHAPTER 2

ORACLE DATATYPES
Amoud University
Faculty of Computing and ICT
Junior classes – BSc IT
Data Types
 Char
 Varchar2
 Date
 Number , integer
 Long
 Raw
 Long Raw

 LOB

 CLOB
 BLOB

 BFILE
Datatypes
• What is DATA TYPE ?

•It is a type of information stored in memory is called as datatype.


•is an attribute(features, characteristics) that specifies what types of data enter by the user such as
number, character, decimal, date time etc. you have to specify a datatype for each of its columns.
• Data types are used to represent the nature of the data that can be stored in the database table.
• For example, in a particular column of a table, if we want to store a string type of data then we will
have to declare a string data type of this column.
CHAR
• 1. CHAR: The data type is used to store alpha numeric values. Number /alph
• It can be also store special symbols like -,: ,/ , * and etc.
• This data type of fixed size.
The Maximum size is 255 bytes.
It is used to specify a fixed length string that can contain numbers, letters, and special characters.
When you insert or update a row in the table, the value for the CHAR column has the fixed length.
Its size can be 0 to 255 characters. Default is 1.

• Note: Memory is not used efficiently.


2.VARCHAR2()
• VARCHAR2: This data type it can store alphanumeric values special symbols like -,:,_ and etc. This
data type is of variable size. Maximum size 4000 bytes.
• Note: Memory is efficiently used.
• it supports Dynamic Memory Allocation.
• -> it accepts alphabets and alpha-numaric values.
• -> max. size is 4000 bytes/chars.
• ex: Ename Varchar2(10); 'ram'
3.NUMBER /integer
• NUMBER(P,S): p-precision/s-scale
• This data type used to store numeric values.
• this datatype accepts numaric values only.
• -> max. limit is 38 digits. Or maximum size 38 digits
• ex: Empno Number(2); 0-99
• Sal Number(5,2); 999.99
• sal number(6,2); 9999.99
DATE
• 4.DATE: This data type is used to store date values it will not have size.
• Default Date format is DD-MON-YY.
Ex:
• Create table student1(SNO number(2),
• SNAME varchar2(20),
• MARKS number(3),
• DOJ Date);
• Insert into student1 values(10,'Raju',99,SYSDATE);
• Date and Time Data Type: These data types are define a particular date and time
of the day.
• Date: It defines date only the default format of date data type is “yy/mm/dd”
• Time: It defines time of the day the default format is “hh/mm/ss.ms”
• Date & Time: This will allows the both date and time of the day.
• “Yy/mm/dd hh/mm/ss.ms”

Vii. LOB/BLOB/CLOB:
-------------------
-> These datatypes also accepts images, audio files and video files.
-> Max. Limit is 4GB.
ex: Photo
long

• 5. LONG is an Oracle data type for storing character data of variable length up to 2 Gigabytes in
length (bigger version of the VARCHAR2 datatype). Note that a table can only have
one LONG column.
• LONG: Similar to varchar2 data type. Maximum size 2 GB.
• Example
• create table dv1(data long);
• insert into dv1 values(12345);
CLOB
• 8.CLOB:(character large object) used to store characters. Maximum size 4 GB.
• CLOB Character Large Object To store large continuous text Max 4GB
• A character large object containing single-byte characters. Both fixed-width and variable-width
character sets are supported, both using the CHAR database character set. Maximum size is
4 gigabytes.
example
create table dv(data clob);
insert into dv values('mako cumar hanfi')
BLOB(binary large object)
• 9. Binary Large Object (BLOB) Definition - What does Binary Large Object (BLOB) mean?
A binary large object (BLOB) is a data type that can store binary objects or data.
• The BLOB(Binary Large Object) datatype stores unstructured binary data in the database. BLOBs
can store up to 128 terabytes of binary data.
• BLOB:(binary large object) used to store binary data. Maximum size 4 GB.
• BLOB To store audio / video files Max 4 GB
example
• create table dv3(data blob);
• insert into dv3 values('123abc');
Raw datatype
• 6. RAW: used to store Images, logos, digital signatures etc.
• Raw To store images (photographs). Max 2000 Bytes
• example
create table dv2(data raw(100));
insert into dv2 values('123abc');
LONG RAW
• 7.LONG RAW: Similar to RAW data type. Maximum size 2 GB.
• Long Raw -> These datatypes supports To store images of larger size Images, audio files and
video files. Max 2GB
• -> Max. limit for RAW(2000 Bytes), LONG RAW(2GB)
• EX: Photo Long RAw;
BFILE (binary file)
• 10. BFILE:(binary file) Contains a locator to a large binary file stored outside the database.
• Enables byte stream I/O acc4 gigabytes.
• ess to external LOBs residing on the database server.
Maximum size is

You might also like