Monday, September 28, 2009

Oracle Datatypes

Oracle Internal Datatypes Oracle supports the following datatypes

1.Character Datatypes

The following are the character datatypes supported by oracle

Char Datatype

The Char datatype is used when a fixed length character string is required. It can stored alphanumeric values.The column length of such a datatype can between 1 - 2000 bytes . By default it is one byte.

Eg: Sex char(1)

Varchar2 Datatype

The varchar2() datatype supports a variable length character string .It also stores Alphanumeric values . The size for this datatype ranges from 1 - 4000 bytes.While Defining this datatype programmer should specify the size using varchar2 saves disk space when compared to char.

Eg: Employeename varchar2(25)

# Currently varchar datatype is equivalent to varchar2 datatype Long Datatype.

The Long datatype is used to store variable character length. Maximum size is 2GB. Long datatype has several characters similar to varchar2 datatype.

The following restriction will be followed when Long datatype used in tables.

1. Only one column in a table can have long datatype.
2. This should not contain unique or primary key constraints.
3. The column cannot be indexed .
4. Procedures or stored procedures cannot accept long datatype as arguments. Eg Feedback Long

2.Number Datatypes

The Number datatype can store positive numbers , negative numbers , zeroes , fixed point numbers , and floating point numbers with a decimal

Egs: Age number(3)
Salary number(10,2)

3.Date Datatypes

Date dataype is used to store date and time in a table.
Date format - "dd - mon - yy".
Limitation of dates between Jan 1 , 4712 BC to Dec 31 , 4712 AD.

Eg: Dob date

4.Raw Datatypes

Raw datatype is used to store bytes based data like binary data or byte strings and the maximum size of this datatype is 2000 bytes.
We must mention storage size when using to raw datatype,because default it does not specify any size P> # Only Storage and Retrieval of data are possible, manipulation of data cannot be done . Raw datatype can be indexed .

Eg: Slno Raw(3)

Long Raw Datatypes

Long Raw datatype is used to binary data of variable length.which can have size of 2 GB .
# This datatype cannot be indexed

Eg: Comments Raw

5.LOB Datatypes

LOB stands for Large Object.This can store unstructured information such as Sound Clips, Video files etc .The maximum size is 4 GB .
The Different internl LOBs are mentioned below

CLOB

A column with its data type as CLOB stores character objects with Single Bytes Characters
CLOB stands for Character Large Object .
A table can have multiple columns with CLOB as its datatype

BLOB

A column with its data type as BLOB can store Large Binary Bytes Objects such as Graphics , Video Clips and Sound Files.
BLOB stands for Binary Large Object .

Eg: Fav_ movie LOB

BFILE

A BFILE column stores File Pointers to LOBs managed by file systems external to the database.A BFILE column may contain filenames for photos stored on a CD-ROM.

Eg: Employee_Photo BFILE