Oracle Data Type

Source: Internet
Author: User
1. Balanced

It is used to store string or character data. The main types include varchar2, Char, and long.

(1) varchar2

Used to store variable-length string or string-type data. during use, you must specify its maximum byte data.

(2) Char

It is used to store fixed-length string or character-type data. You must specify the length during use. The default value is 1.

(3) Long

It is used to store variable-length string or string-type data.

2. Digital

The numeric type is used to store integers or real numbers. Mainly include: Number, binary_integer

(1) numer

Used to store numeric data, including integer or floating point numbers. In practice, the length and decimal digits of the data type should be specified. The Length Specified in Oracle does not contain the decimal point and symbol bit.

(2) binary_integer

It is a data type of PL/SQL. It is used to store signed integer values in the binary format of 2's complement code.

3. date type

The date type is used to store date and time information, including Century, sum, month, day, hour, minute, and second. Each part occupies seven bytes.

4. Raw and long raw

Raw and long raw are used to store binary data.

(1) Raw

Raw is similar to Char and must specify the maximum number of bytes to store binary data.

(2) Long raw

Long raw is similar to long.

5. rowid

Each row in the database table has an address, which is obtained by querying the pseudo-column rowid. The value of this pseudo column is a hexadecimal string and the Data Type of this string is rowid. The character value is in the form of block. Row. File.

6. Boolean

There is no Boolean field type in the table. Only the boolean type can be defined in PL/SQL. Its values are true, false, and null. When defining a Boolean variable, the variable can be limited to not null, but must be initialized at this time.

7. Composite Type

(1) Record

The record format is as follows:

Type record_type is record (

Field1 datatype1 [not null] [: = expression1],

Field2 datatype2 [not null] [: = expression2],

...);

In the preceding format, record_type is a defined record type.

If you want to define a variable of the record type to be consistent with the structure of a created relational table, you can use the following definition:

Record_typename table_name % rowtype;

(2) Table

The tables in PL/SQL are similar to the arrays in C language and the processing method of the arrays is similar, but the implementation method is different. The table must define the table type and declare a variable of this type before reference. The format of the table type is as follows:

Type table_type is table of type index by binary_integer;

A pl/SQL table is similar to a table with only two columns in the database. The type of one column is binary_integer, and the type of the other column is the type specified in the definition.

8. lob type

The lob type is used to store large objects. It can be a binary value or numeric value, and its maximum length is 4 GB. Lob can contain data without structural features, which is more effective than long or long raw data and has less restrictions on it.

9. Custom child types

In PL/SQL, except for pre-defined child types, you can define the child types in the following format:

Subtype new_type is original_type

10. Use % Type

In many cases, PL/SQL variables can be used to process data stored in database tables. Therefore, the variable type is the same as the data type of the corresponding field in the table. You can use % type to indicate that a variable has the same field type as the table. The format is:

Variety_name table_name.field_name % type;
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.