 |
|
EnterpriseDB: RAW & BLOB
Oracle Tips by Burleson Consulting
|
In
Oracle, we have several types of database resident binary fields.
RAW is used to store smaller binary strings, like an encrypted
password. BLOB is used to store Binary Large Objects.
In
EnterpriseDB, the BYTEA data type works in place of those two data
types. BYTEA does not allow a maximum size to be declared.
The field will grow to handle the binary data (up to about 1GB).
When
manually entered, the binary data is represented by a three digit
octal number. Don't let that scare you. I doubt you will
need to worry about manually keying binary data very often. It
wouldn't hurt my feelings at all if you just skipped this section
and came back to it should you ever need to manually type binary
data.
There
are special "escaping" issues with the BYTEA data type that are
talked about in the EnterpriseDB documentation. Most
interfaces that support EnterpriseDB (or PostgreSQL) will have no
problem loading binary data.
To
"escape" the data means to preface it with a back slash (\).
In most instances when you "escape" data, you put a single back
slash in front of it. In EnterpriseDB, when you manually enter
the binary data, you will need to use double slashes (\\).
A
binary null (0) is represented as '\\000'.
The
octal value of the character for a semi colon, ';' is '\\073'.
You can verify this in Oracle by using the DUMP function:
SELECT
dump(';', 8) FROM DUAL;
The
second parameter tells the DUMP function which format to return the
results in: 8 is for octal, 16 is for hexadecimal and 10 is
for decimal.
Results:
DUMP(';',8)
-----------------
Typ=96 Len=1: 73
1 row selected.
So the
data type is 96, which means character, the length of the data is 1
and the octal value is 73. If you were entering this data as a
string, you would use: '\\073'.
In
EnterpriseDB, a BLOB (alias is also RAW) is the preferred choice for
storing binary data. A BLOB column can store about 1GB of data
so it should be sufficient for most purposes.
Synonyms for BLOB are:
*
BINARY
* BYTEA
* BYTE
* IMAGE
* LONG RAW
* RAW(n)
* VARBINARY
This
is an excerpt from the book "EnterpriseDB:
The Definitive Reference" by Rampant TechPress.