background image
<< BIGINT data type | CHAR data type >>

BLOB data type

<< BIGINT data type | CHAR data type >>
Derby Reference Manual
193
When mixed with other data types in expressions, the resulting data type follows the rules
shown in
Numeric type promotion in expressions
.
An attempt to put an integer value of a larger storage size into a location of a smaller size
fails if the value cannot be stored in the smaller-size location. Integer types can always
successfully be placed in approximate numeric values, although with the possible loss of
some precision. BIGINTs can be stored in DECIMALs if the DECIMAL precision is large
enough for the value.
Example
9223372036854775807
BLOB data type
A BLOB (binary large object) is a varying-length binary string that can be up to
2,147,483,647 characters long. Like other binary types, BLOB strings are not associated
with a code page. In addition, BLOB strings do not hold character data.
The length is given in bytes for BLOB unless one of the suffixes K, M, or G is given,
relating to the multiples of 1024, 1024*1024, 1024*1024*1024 respectively.
Note: Length is specified in bytes for BLOB.
Syntax
{ BLOB | BINARY LARGE OBJECT } [ ( length [{K |M |G }] ) ]
Default
A BLOB without a specified length is defaulted to two gigabytes (2,147,483,647).
Corresponding compile-time Java type
java.sql.Blob
JDBC metadata type (java.sql.Types)
BLOB
Use the getBlob method on the java.sql.ResultSet to retrieve a BLOB handle to the
underlying data.
Related information
See
Mapping of java.sql.Blob and java.sql.Clob interfaces
.
Example
create table pictures(name varchar(32) not null primary key, pic
blob(16M));
-- find all logotype pictures
select length(pic), name from pictures where name like '%logo%';
-- find all image doubles (blob comparisons)
select a.name as double_one, b.name as double_two
from pictures as a, pictures as b
where a.name < b.name
and a.pic = b.pic
order by 1,2;
BOOLEAN data type
BOOLEAN provides 1 byte of storage for logical values.