Oracle basic Data type-raw type ____oracle

Source: Internet
Author: User

The data type used to hold the bit string in Oracle is Raw,long RAW (the recommended use of BLOBs).

Raw, similar to char, declared as Raw (L), L is length, in bytes, as the largest database column 2000, as a variable of the largest 32767 bytes.

Long RAW, similar to long, is the largest storage database column of 2G bytes of data, as a variable of the maximum 32760 bytes

The benefit of the raw type is that the Oracle server does not perform character set conversion when raw data is transferred between computers on the network, or when raw data is moved from one database to another using the Oracle utility. The number of bytes required to store the actual column value varies with the size of each row, up to 2,000 bytes. It is possible that such data types increase in database efficiency, and that the likelihood of inconsistencies in data due to different character sets is also excluded here.

Here is the official definition:
Note:

The LONG RAW datatype is provided to backward compatibility with existing applications. For new applications, use the BLOB and bfiledatatypes for large amounts of binary data.

the raw and long raw datatypes are used for data, Ed when moving the data between different systems) by Oracle. These datatypes are intended for binary data or byte strings. For Example, long raw can is used to store graphics, sound, documents, or arrays of binary data. The interpretation depends on the use.

Raw is a variable-length datatype like The varchar2 character datatype, except Oracle Net Services ( Which connects user sessions to the instance) and the Import and Export utilities does not perform character when Transmitting raw or long raw data. In contrast, Oracle Net Services and Import/export automatically convertchar, varchar2, and long data Between the database character set and the user session character set (set by The nls_language parameter of the& nbsp ALTER session statement), if the two character sets are different.

When Oracle automatically converts raw or LONG raw and from CHAR data, the binary data was represented in Hexad Ecimal form with one hexadecimal character representing every four bits of RAW data. For example, one byte of RAW data with bits 11001011 is displayed and entered as ' CB. '

LONG raw data cannot is indexed, but raw data can be indexed.

functions that are commonly used to manipulate RAW types: Utl_raw. Cast_to_raw,hextoraw.

Raw is saved as a 16-in number. When using Hextoraw, the data in the string is treated as a 16 number. and use Utl_raw. When Cast_to_raw, the ASCII code for each character in the string is stored directly in the raw Type field.

Here are two functions that are commonly used:
Utl_raw.cast_to_raw ([varchar2]);--convert varchar2 to RAW type
UTL_RAW.CAST_TO_VARCHAR2 ([raw]);--Convert Raw to VARCHAR2 type
Here the VARCHAR2 character set is generally GB2312.
Because Raw is saved as a 16-in number. So the following SQL will complain: INSERT into Test_raw values (Hextoraw (' hh '))
INSERT into Test_raw values (Hextoraw (' hh '))
*
ERROR is on line 1th:
ORA-01465: Invalid hexadecimal number

Raw type data columns commonly used bit operations:
Utl_raw.bit_or ();
Utl_raw.bit_and ();
Utl_raw.bit_xor ();

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.