A detailed description of various data types in Oracle

Source: Internet
Author: User

When you create a data table in a database, you need to define the types of all the fields in the table. Oracle has a number of data types to meet your needs. Data types are roughly divided into: character, number, date, LOB, and Raw. Although Oracle8i also allows you to customize data types, they are the most basic data types.

In the following article you will learn about their usage, limitations, and allowable values in Oracle. The

Character data type
Character data type is used to store alphanumeric data. When you define a character data in Oracle, you usually need to set the length of the field, which is the maximum length of the field. Oracle provides the following kinds of character data types: the

char () Char data type is a string with a fixed length and a maximum length. Data stored in a Char field in the data type is filled with a space to the maximum length. The length is defined between 1--2000 bytes.

When you create a char field, the database guarantees that all data in the field is defined as a length, and if a data is shorter than the defined length, then a space is added to the right of the data to define the length. If the length is greater than the defined length, the error message is triggered. The

VARCHAR () VARCHAR data is a snapshot of the type of VARCHAR2 data. The

VARCHAR2 () varchar2 data type is a variable-length alphanumeric data with a maximum length. The VARCHAR2 type can have a field length of 4000 bytes and a Varchar2 type with a variable length of up to 32676 bytes.

The space occupied by an empty VARCHAR2 (2000) field and an empty VARCHAR2 (2) field is the same. The

NCHAR () and NVARCHAR2 () NCHAR () and NVARCHAR2 () data types are the same as the char () and VARCHAR2 () types, except that they are used to store the NLS (National Language Sup Port) data. The

Long data type is a data type that is left behind and will not be supported in the future. It will be replaced by the LOB (Large Object) data type. The

Comparison rule Varchar2 and char data types have different comparison rules depending on the trailing spaces. For char data, the trailing spaces are ignored, and the data for the trailing spaces of the VARCHAR2 data are sorted much larger than the blank spaces. For example:

Char data: ' Yo ' = ' yo '

Varchar2 type data: ' Yo ' < ' yo '


  
Numberic data type
  
Numberic data types are used to store negative and positive integers, fractions, and floating-point data, ranging in -1*10-103 and 9.999 ... Between 99*10125, there are 38 digits of precision. An error occurs when you identify a data that is outside this range.
  
The number (,) Number data type stores an S-bit-level data with a P-bit precision.
  

DATE data type
Date data types are used to store data in dates and time formats. This format can be converted to other formats of data to browse, and it has special functions and properties to control and compute. Several of the following information are included in the date data type:
  
Century
  
Year
  
Month
  
Day
  
Hour
  
Minute
  
Second


  
LOB data type
LOB (Large Object) data types store unstructured data, such as binary files, graphics files, or other external files. LOB can be stored to 4G byte size. Data can be stored in a database or stored in an external data file. Control of LOB data is implemented through DBMS_LOB packages. BLOBs, NCLOB, and CLOB data can be stored in different table spaces, bfile stored in external files on the server. LOB data types are available in the following ways:
  
BLOB: Binary data
  
CLOB: Character-type data
  
BFILE: Binary file
  

Other data types
  
The ROWID ROWID data type is a pseudo column in an Oracle datasheet, which is the unique identity within each row of data in the datasheet.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.