Tuesday 22 March 2011

Oracle Data Types

PL/SQL is a Programming Language with SQL commands. Since oracle is an RDBMS, we can not define our own programs by only using it. That’s why it supports a language called PL/SQL. We can compile the sql and non sql statements for performing an action that is related to either a data in the data base or not related to data base.

Oracle Data types :

The information in a database is maintained in the form of table, each table consists of rows and columns to store the data. A particular column in a table must contain similar data, which is of a particular type.

The following are different data types supported by ORACLE

1. CHAR This data type is used to store fixed length character of the specified length. Where the maximum size is 255 bytes for columns/rows.

Syntax: char (size)

Example : Result char(4)

2. VARCHAR2 This data type is used to store variable length characters.

Maximum it can take is 2000 bytes for columns/row.

Syntax: varchar2 (size)

Example : sname varchar2(15)

3. NUMBER this data type is used to store both numbers and numbers with decimal pointes. It can take maximum precision up to 38 digits after decimal.

Syntax: Number(value, precisions)

Example : Empno number(5) -> Pure Integers

Sal number(6,2) -> Numbers With Decimals

4. DATE This data type is used to store date and time in a table. The date data types stores year (including the century) . the month, the days, hours, minutes, seconds. The maximum size is 7 bytes for each row in a table.

Syntax: Date

Example : Doj Date

5. LONG This data type is used to store variable length character containing up to 2 GB of information.

Syntax: Long

Example : Remarks Long

Restriction of Long

There are some restrictions of long data type.

1) Only one column is defined as long for table.

2) Long columns con not be indexed.

3) Long columns can’t appear in integrity constraints.

4) Long columns can’t be used in SQL expressions.

5) Long columns cannot be referenced by the SQL function

2 comments :