When you create a table in a database, you need to define the types of all fields in the table. ORACLE has many data types to meet your needs. Data types are roughly divided into: character, number, date, LOB, and RAW types. 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 allowed values in Oracle.
Character data type
The Character data type is used to store alphanumeric data. When you define a character data in Oracle, you usually need to specify the length of the field, which is the maximum length of the field. ORACLE provides the following character data types:
CHAR() The CHAR data type is a string with a fixed length and a maximum length. Data stored in fields of data type CHAR will be padded with spaces to the maximum length. The length is defined between 1-2000 bytes.
When you create a CHAR field, the database will ensure that all data in this field is of the defined length. If a piece of data is shorter than the defined length, spaces will be used to pad the right side of the data to the defined length. An error message will be triggered if the length is greater than the defined length.
VARCHAR() varchar type data is a snapshot of varchar2 type data.
VARCHAR2() The varchar2 data type is a variable-length, alphanumeric data with a maximum length. The field length of Varchar2 type can reach 4000 bytes, and the variable length of Varchar2 type can reach 32676 bytes.
An empty varchar2(2000) field takes up the same space as an empty varchar2(2) field.
NCHAR() and NVARCHAR2() The NCHAR() and NVARCHAR2() data types are the same as the CHAR() and VARCHAR2() types respectively, except that they are used to store NLS (National Language Support) data.
LONG The LONG data type is a legacy data type and will not be supported in the future. It will be replaced by the LOB (Large Object) data type.
Comparison rules Varchar2 and char data types have different comparison rules based on trailing spaces. For Char type data, trailing spaces will be ignored. For Varchar2 type data, the sorting of data with trailing spaces is larger than that without spaces. for example:
Char type data: 'YO'='YO '
Varchar2 type data: 'YO'<'YO '
Numberic data type The Numberic data type is used to store negative and positive integers, fractions and floating-point data, ranging from -1*10-103 to 9.999...99*10125, with 38-bit precision. An error occurs when identifying a data that exceeds this range.
Number(,) The Number data type stores an s-bit level data with p-bit precision.
DATE data type
The DATE data type is used to store data in date and time format. This format can be converted to data in other formats for browsing, and it has specialized functions and properties for control and calculation. The following information is included in the DATE data type:
Century
Year
Month
Day
Hour
Minute
Second
LOB data type LOB (Large Object) data type stores unstructured data, such as binary files, graphics files, or other external files. LOBs can be stored up to 4G bytes in size. Data can be stored in the database or in external data files. The control of LOB data is implemented through the DBMS_LOB package. BLOB, NCLOB, and CLOB data can be stored in different table spaces, and BFILE is stored in an external file on the server. LOB data types include the following:
BLOB: Binary data CLOB: Character data BFILE: Binary file other data types ROWID The ROWID data type is a pseudo column in the ORACLE data table, which is the inherent unique identifier of each row of data in the data table.
This article comes from the CSDN blog. Please indicate the source when reprinting: http://blog.csdn.net/chenliubin/archive/2009/12/21/5046504.aspx
-