Find strings in Blob type data in oracle

 

  Prospect review:     Just a big MM asked me how to query the string of Blob type data.

  Solution:     Use dbms_lob.instr and CAST_TO_RAW to solve:

   Example:

    select * from tesu where dbms_lob.instr(msg,utl_raw.CAST_TO_RAW('darren'),1,1) >0.

  

   extension:

    1), Insert: You can use the to_blob function

                insert into tesu(msg)  values(to_blob('adddda')) ;

           Another is to use the empty_blob() function to insert an empty one first, and then insert the value

          Java uses jdbc, simple and slightly.

     2). Update: still use to_blob

          update tesu set msg = to_blob('adddda')  where id =1;

 

     3) Difference from clob

      BLOB stands for Binary Large Object.

                      It is used to store large binary objects in the database. The maximum size that can be stored is 4G bytes  

      CLOB stands for Character Large Object. It is similar to LONG data type,

      It's just that CLOB is used to store large single-byte character data blocks in the database, and does not support character sets of varying widths .

      The maximum size that can be stored is 4G bytes

    4), performance: do not use as much as possible

           ???

    5), other

           a. A Blob/Clob field includes lobindex and lobsegment

           b. Lob can be stored in a table (table field) by default, provided that:

               1. Its size is less than 4kb

             2. And the (disable storage inrow) clause is not used in the definition (the default is enable)

                When the lob is larger than 4kb, it will be stored in the lobsegment

     c. When the lob is stored in the table, it can be cached,

                 Its operation efficiency is much higher than that of lob stored in lobsegment (without lobindex)

     d. The lob stored in the lobsegment is not in the buffer cache by default. The reading and writing of the lob are all physical IO, and the cost is very high.

                 Therefore, for lob fields larger than 4kb, do not update frequently, the efficiency is very low

     e. The lob stored in the lobsegment can be specified to use the cache when it is defined (the default is nocache),

                 This is very effective for medium-sized lobs (such as a few k to dozens of k), reducing physical IO

 

   An unrelated note:

        The MM referenced its own table in her trigger to perform queries and other operations, and then reported an error..

        Solution: You can directly use the current record to perform the corresponding operation, do not substitute it into the current operation table. 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326090031&siteId=291194637