RAW is an Oracle data type for storing variable length binary data. Maximum size is 2000 bytes (the maximum length in Oracle 7 was 255 bytes).
[edit]Examples
Create a table with a RAW column:
CREATE TABLE t1 (id NUMBER, doc RAW(2000));
INSERT INTO t1 VALUES (1, 'F1F2F3');
Values for RAW columns must be specified in hex. If not, you will get error:
SQL> INSERT INTO t1 VALUES (1, 'A RAW Value');
INSERT INTO t1 VALUES (1, 'A RAW Value')
*
ERROR at line 1:
ORA-01465: invalid hex number
However, this will work:
INSERT INTO t1 VALUES (1, utl_raw.cast_to_raw('A RAW Value'));
To get the data back as readable text:
SELECT utl_raw.cast_to_varchar2(doc) FROM t1;
[edit]Examples
Create a table with a RAW column:
CREATE TABLE t1 (id NUMBER, doc RAW(2000));
INSERT INTO t1 VALUES (1, 'F1F2F3');
Values for RAW columns must be specified in hex. If not, you will get error:
SQL> INSERT INTO t1 VALUES (1, 'A RAW Value');
INSERT INTO t1 VALUES (1, 'A RAW Value')
*
ERROR at line 1:
ORA-01465: invalid hex number
However, this will work:
INSERT INTO t1 VALUES (1, utl_raw.cast_to_raw('A RAW Value'));
To get the data back as readable text:
SELECT utl_raw.cast_to_varchar2(doc) FROM t1;
No comments:
Post a Comment