Get the App
SLTechnology News&Howtos  ›  Database  › 

Analysis of Oracle basic data type storage format-- RAW type

Shulou Source: shulou.com Published: 2022-06-01 04:58:39 09月16日 Update

Original link: https://www.modb.pro/db/23307?xy

Summary: describes the RAW type storage format for Oracle

Compared with other data types, the storage of the RAW type is much more intuitive, and it is exactly the same as the value displayed by the data in SELECT. (SELECT is shown in hexadecimal)

SQL > create table test_raw (id number, raw_date raw (10)); table created. SQL > insert into test_raw values (1, hextoraw ('ff')); 1 line has been created. SQL > drop table test_raw; table has been discarded. SQL > create table test_raw (raw_col raw (10)); table created. SQL > insert into test_raw values (hextoraw ('ff')); 1 line has been created. SQL > insert into test_raw values (hextoraw ('0')); 1 line has been created. SQL > insert into test_raw values (hextoraw ('23fc')); 1 line has been created. SQL > insert into test_raw values (hextoraw ('fffffffffff')); 1 line has been created. SQL > insert into test_raw values (hextoraw ('ffffffffffffffffffff')); 1 line has been created. SQL > insert into test_raw values (utl_raw.cast_to_raw ('051')); 1 line has been created. SQL > select raw_col, dump (raw_col, 16) dump_raw from test_raw RAW_COL DUMP_RAW- FF Typ=23 Len=1: ff00 Typ=23 Len=1: 023FC Typ=23 Len=2: 23c0FFFFFFFFFF Typ=23 Len=6: FLIFF 6 lines have been selected for ff,ff,ff,ffFFFFFFFFFFFFFFFFFFFF Typ=23 Len=10: ff,ff,ff,ff,ff,ff,ff,ff,ff,ff303531 Typ=23 Len=3: 30, 35, and 31.

The storage of the RAW type is simple, and it is easy to compare the query results of the fields with the results of the DUMP.

It is important to note the difference between the two functions that are converted to RAW. When using HEXTORAW, the data in the string is treated as a hexadecimal number. When using UTL_RAW.CAST_TO_RAW, the ASCII code of each character in the string is directly stored in a field of type RAW.

SQL > insert into test_raw values ('gg'); insert into test_raw values (' gg') * ERROR is on line 1: ORA-01465: invalid hexadecimal number SQL > insert into test_raw values (hextoraw ('gg')) Insert into test_raw values (hextoraw ('gg')) * ERROR is on line 1: ORA-01465: invalid hexadecimal number SQL > insert into test_raw values (utl_raw.cast_to_raw (' gg')); 1 line has been created. SQL > select raw_col, dump (raw_col, 16) dump_raw from test_raw RAW_COL DUMP_RAW--FF Typ=23 Len=1: ff00 Typ=23 Len=1: 023FC Typ=23 Len=2: 23 Fc6767 Typ=23 Len=2: 67670FFFFFFFFFFF Typ=23 Len=6: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

Tags: Type data storage character hexadecimal field string number result base selection format intuitive at a glance between function text difference summary link Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Apple Xiaomi macOS Redmi