RAW Data Type
In Oracle DBA world there is some confusion between LONG RAW and LONG data types on one hand and RAW datatype on the other hand. LONG and LONG RAW has been deprecated for many years and replaced with CLOB and BLOB while RAW is still supported. In fact, you can create an index on RAW data type.
?
If your application requires the use of binary data without any character-set conversion between Oracle Server and Oracle client then RAW data type is the proper data type to use. Older DBAs – like myself - had to change character-set to view Arabic characters correctly. Since Oracle 11g, character-set default has changed to UTF-8.
You can use bit-manipulation operations such as AND, OR and XOR functions that are available in utl_raw package.
You can insert functions with output RAW like sys_guid.
Raw data type maximum?size:
?
A quick example:
Create table test_raw
(
? col1 raw(100)
);
Insert into test_raw values ('test string');
ORA-01465: invalid hex number
?
Insert into test_raw values (utl_raw.cast_to_raw('test string'));
1 row inserted.
?
Insert into test_raw values (sys_guid());
1 row inserted.
?
select * from test1;
?
COL1
___________________________________
7465737420737472696E67
2EDFA1C3FC056C48E063AB3B150A857F
?
?
create index test1_idx on test_raw (col1);
Index TEST1_IDX created.
?
?
?
Oracle Database Administrator & Developer
3 周Useful tips
Senior Oracle Database Administrator @ DETASAD
3 周Useful tips