Blob refers to the writing of a binary large object, that is, an English Binary large object;
Clob refers to a large character object, that is, written by the English character large object.
Therefore, these two types are designed to store a large amount of data, blob is used to store a large amount of binary data, and clob is used to store a large amount of text data.
There are two interfaces in JDBC that correspond to the blob and clob types in the database, java. SQL. Blob and Java. SQL. clob. You can use the resultset. getblob () method to obtain the object of this interface. The only difference from the usual search is that after we get blob or clob objects, we don't get any data, but we can get data through the methods in these two interfaces.
For example:
Blob B = resultset. getblob (1 );
Inputstream bin = B. getbinarystream ();
Clob c = resultset. getclob (2 );
Reader creader = C. getcharacterstream ():
Another method is to obtain data blocks instead of data streams.
For example
Blob B = resultset. getblob (1 );
Byte data = B. getbyte (0, B. Length ());
Clob c = resultset. getclob (2 );
String STR = C. getsubstring (0, C. Length ());
This method is actually not safe. If you are very careful, you can easily find getbyte () and getsubstring () the second parameter in both methods is of the int type, while blob and clob are used to store a large amount of data. The return values of bolb. Length () and clob. Length () are of the long type, so it is not safe.
So someone must ask why the other two types have to be used since there are already varchar and varbinary types?
Cause: varchar and varbinary have their own limitations. The length of the two types is limited and cannot exceed a certain limit. The length of a varchar instance in ora cannot exceed 4000; one important defect of the longvarchar type is that you cannot use like-like conditional search.
In addition, in the database, varchar and varbinary are used to read or write all the content. For K or larger data, such a read/write method is used, it is far more practical than stream-based read/write.