Oracle SQL clob queries duplicate data with multiple fields

Source: Internet
Author: User

Oracle SQL clob queries duplicate data. Multi-field COMPARE function data clob fields cannot be group by or distinct during query. Therefore, it is very troublesome to find duplicate data based on clob, most people on the Internet propose to use DBMS_LOB.SUBSTR to solve the problem. DBMS_LOB.SUBSTR converts clob into string segments and then performs group by. In addition, if there are too many words, segment conversion is required. This operation is too troublesome, in addition, it is easy to see the error that the string buffer is too small. After searching the Internet for a long time, we suddenly found that Dbms_Lob.Compare can solve this problem. COMPARE functions the COMPARE function is used to COMPARE the two large objects with a given degree of length for a given offset. This function returns zero. If two large objects have the same length as zero for the specified offset, if the objects do not have the same null value, if amount, offset_1, or offset_2 is less than zero. The type of large objects of the same region must be the same. The following is my final SQL statement. remark is the clob field.

1 Select * From Userinfo Where Id In (2 Select U. Id From Userinfo U, Userinfo User_Info3 Where U. Id! = User_Info.Id4 And U. typeid = User_Info.Typeid5 And u. theTime = User_Info.theTime6 And u. createId = User_Info.createId7 And Dbms_Lob.Compare (u. remark, User_Info.Remark) = 08 Group By u. id9) Order By id;

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.