MY mENU


Wednesday 7 March 2012

DataTypes in Oracle


Datatypes:
Each column of the table contains the datatype and maximum length, if it is length is applicable. Datatype of the column specifies what type of data can be stored in the column. The datatype VARCHAR2 is to store strings that may have different number of characters, NUMBER is used to store numbers. The maximum length, which is given in parentheses after the datatype, specifies how many characters (or digits) the column can store at the most. For example, column VARCHAR2 (20) would mean it can store up to 20 characters.

Datatype Description:

VARCHAR2( len): Can store up to len number of characters. Each character would occupy one byte. Maximum width is 4000 characters.VARCHAR(len) Same as VARCHAR2. But use VARCHAR2 as Oracle might change the usage of VARCHAR in future releases. 

CHAR(len): Fixed length character data. If len is given then it can store up to len number of characters. Default width is 1. String is padded on the right with spaces until string is of len size. Maximum width is 2000.

NUMBER: Can store numbers up to 40 digits plus decimal point and sign. NUMBER (p ,s) P represents the maximum significant digits allowed. S is the number of digits on the right of the decimal point.

DATE: Can store dates in the range 1-1-4712 B.C to 31-12-4712AD.

LONG: Variable length character values up to 2 gigabytes. Only one LONG column is allowed per table. You cannot use LONG datatype in functions, WHERE clause of SELECT, in indexing and subqueries.
RAW and LONG RAW Equivalent to VARCHAR2 and LONG respectively, but used for storing byte-oriented or binary data such as digital sound or graphics images.

CLOB, BLOB, NCLOB Used to store large character and binary objects. Each can accommodate up to 4 gigabytes. 

BFILE Stores a pointer to an external file. The content of the file resides in the file system of the operation system. Only the name of the file is stored in the column.

ROWID Stores a unique number that is used by Oracle to uniquely identify each row of the table.

NCHAR (size) Same as CHAR, but supports national language.

NVARCHAR2 (size) Same as VARCHAR2, but supports national language.

No comments:

Post a Comment