Oracle Raw Type

Source: Internet
Author: User

Raw (size): The original binary data of size byte, the maximum value of size is 2000 bytes;
Raw type benefits: When raw data is transferred between computers in the network, or when raw data is moved from one database to another using the Oracle utility, the Oracle server does not perform character set conversions.
Raw, similar to Char, declares the way Raw (L), L is the length, in bytes, as the database column maximum of 2000, as a variable up to 32767 bytes.
Long RAW, similar to long, stores up to 2G bytes of data as a database column, up to a maximum of 32760 bytes as a variable;

Operation:
Create TableRaw_test (ID Number, Raw_dateRaw(Ten)); Insert  intoRaw_testValues(1, Hextoraw ('FF')); Insert  intoRaw_testValues(2, Utl_raw.cast_to_raw ('ABC')); Insert  intoRaw_testValues(3, Utl_raw.cast_to_raw ('Hello, you, you.'));SELECTR.*,DUMP(r.raw_date), Rawtohex (r.raw_date), Utl_raw. CAST_TO_VARCHAR2 (R.raw_date) fromraw_test R;-----------------------------------------------------------------------------ID raw_dateDUMP(r.raw_date) Rawtohex (r.raw_date) Utl_raw. Cast_to_varchar2 (R.RAW1FF TYP= at Len=1:255FF2        616263Typ= at Len=3: the,98, About       616263ABC3C4E3BAC3C4E3C4E3B5C4 TYP= at Len=Ten:196,227,186,195,196,227,196,227,181,196C4E3BAC3C4E3C4E3B5C4, Hello, you, you.

Several functions are used here:

1. Utl_raw. Cast_to_raw: The function follows the default character set (typically GB2312), converts the VARCHAR2 string to raw, and stores the ASCII code of each character in the string directly into a field of the raw type.

2.utl_raw. CAST_TO_VARCHAR2: This function converts raw to VARCHAR2 according to the default character set (typically GB2312).

3.HEXTORAW (String): When using Hextoraw, the data in the string is treated as a 16-digit number, and every two characters in the string represent a byte in the result raw.

4.RAWTOHEX (RawValue): Converts the raw class numeric RawValue to a string corresponding to the hexadecimal representation. Each byte in the RawValue is converted to a double-byte string. Rawtohex and Hextoraw are the two opposite functions.

 
In fact, raw and varchar are similar, just stored in raw is a binary value, at any time do not do automatic character set conversion, which is the difference between raw and varchar, RAW is just an external type, its internal storage is Varraw
  

Oracle Raw 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.