像带通配符的LIKE(%)在4000char + Clob列上不起作用

时间:2019-06-11 08:03:51

标签: oracle oracle11g

请参见下面的示例。似乎LIKE上的CLOB 不能可靠地与通配符(%)一起使用,即使Clob的字符数超过4000个,即使 / strong>搜索到的字词在前4000个字符中。在下面的示例中,LIKE%一起使用,只要Clob的字符数少于〜16.000。

我的问题是:规则是什么?在LIKE列上使用CLOB通常是不安全的吗?

下面,我将创建3个Clob,它们共享前4000个字符,但是之后添加的字符数不同。使用LIKE%查询前几个字符时,最长的CLOB不会显示。

create table test (col_ clob,id_ number);

insert into test values (null,1);
insert into test values (null,2);
insert into test values (null,3);

-- all 3 get the first part
update test 
set col_ = col_||to_clob(
'step A: 1514 JBPM_TASKINSTANCE cancelled. IDs: 647881560,649669434,646432837,649847575,685046256,682731832,696807202,729925679,754283519,1575869371,873593668,888156478,865437185,889938643,941358497,947331441,973924170,1004124097,956249253,985498887,993206349,1109217579,1113300475,1144065340,1121718658,1128874348,1132468962,1138225634,1161491440,1199842072,1167246496,1185675581,1185044258,1179241140,1201617298,1201620462,1271504575,1291166065,1192439215,3450764985,1223478198,1226377388,1255098113,1258049301,1269483039,1389172034,1538320916,1534506215,1275308781,1448218781,1289019720,1341518604,1327111775,1297656789,1359220594,1342185941,1441269423,1358786499,1346828156,1812130914,1369567075,1766470453,1406441839,1430601916,1382175115,1401183081,1417629193,1380436355,1415414339,1447863326,1383156946,1390952690,1407314398,1410736721,1392649751,1490242158,1410387508,1403002954,1424027725,1413554547,1421846137,1431616842,1413533036,1434584737,1419348181,1432340980,1408509756,1408521234,1448035789,1448042204,1447510642,1421788750,1427007414,1415789790,1813497522,1440200203,1416728688,1652058498,1695890932,1426493489,1444985100,1426494760,1442468948,1418941443,2517649728,1423975229,1424358396,1432004425,1432004499,1444254532,1435954215,1435940114,1424490615,1479853329,1449890691,1424864700,1447465392,1440758412,1427632533,1459066933,1429282077,1442449472,1443061577,1431582495,1489712417,1451975060,1452073020,1496841245,1471863494,1486875131,1450759726,1437070401,1440522983,1435627601,1481721692,1483418393,1449062035,1436139973,1446723840,1439503531,1438312481,1506528866,1449572942,1449571875,1444722671,1506587882,1506076622,1444646698,1444022457,1517968698,1464420387,1443390656,1444065109,1447437473,1446091008,1447437430,1446308056,1499707484,1498740025,1449389032,1750789625,1794298856,1782484488,1446636097,1490628913,1472680258,1450487454,1450483336,1463599647,1449342516,1526095367,1498416881,1510527772,1494010287,1510523510,1536736763,1449746866,1456217730,1480364649,1456832877,1456223078,1456227316,1462863514,1491518804,1456237182,1456228366,1451840612,1456239303,1456239233,1456242805,1482379025,1457093835,1452573038,1456245907,1462776168,1463785759,1473381464,1473379783,1496841626,1462781742,1462778861,1462779264,1463647317,1494655551,1494660729,1511313831,1500663718,1464338851,1488982535,1462781310,1471736830,1471750024,1471737562,1471738197,1471755185,1471755096,1471762795,1511568600,1466798095,1479747554,1479752363,1473570441,1537608976,1499412932,1499415480,1512243488,1480308307,1486666480,1480962849,1486665508,1481436614,1501550975,1486780904,1518187792,1486667712,1526232281,1506233646,1490557756,1578967963,1566489212,1490551633,1505341900,1487510242,1490021956,1490424078,1501501987,1501502117,1518190250,1511571712,1488221604,1493157335,1488347379,1490027853,1490031886,1490988765,1491232970,1503175011,1492093737,1496771353,1513769803,1497229557,1632815098,1508150446,1496424493,1496989437,1497872367,1498339923,1498416395,1515024054,1535110893,1715000701,1747199593,1716957407,1520608484,1498618849,1498864471,1500390533,1513243006,1500409850,1502229523,1503656100,1504535841,1504316349,1506022713,1505095606,1511200028,1511198587,1565677687,1507333027,1526174760,1505496278,1506674775,1515741966,1510036898,1520451282,1520457157,1511558322,1559020441,1548560372,1508297707,1526331083,1512341505,1530413597,1578882543,1598485601,1536307196,1517080210,1524922405,1527649735,1559014115,1609896003,1526296264,1547202944,1527617961,1652035189,1715005200,1529240326,1528138645,1528975612,1538130873,1538132407,1529421257,1530451370,1536562229,1545889137,1541450771,1569934159,1632816780,1536319959,1566300852,1536547612,1537623906,1558345580,1540471856,1557925618,1540301650,1575175744,1544301327,1542771803,1542884750,1574216870,1580479328,1557363359,1543677212,1569878359,1548402377,1547043476,1580579904,1552147778,1575411424,1557622105,1552352560,1582687415,1576265186,1552766622,1563207756,1552552879,1573948291'
)
where id_ in (1,2,3)
;

-- only 2 and 3 get the second part
update test 
set col_ = col_||to_clob(
',1553526018,1565235619,1557983068,1557388741,1563686317,1580283324,1577644453,1563216021,1569983475,1594070305,1635807479,1569896665,1601970391,1602285356,1598928800,1574005625,1593288801,1598668878,1571111568,1575242739,1573391009,1573685559,1574181957,1599930275,1602285355,1601979898,1812453186,1830844044,1572930315,1596453870,1652078234,1711545596,1801825083,1576109074,1574717177,1627592524,1574805822,1579689917,1582968490,1578921490,1579221408,1594857586,1607244162,1579574377,1579931414,1582141417,1580871080,1581011785,1594078626,1583289978,1594069017,1582028459,1807070553,1582081896,1598457272,1680620771,1661308597,1590557490,1583733791,1583969283,1584010015,1589261456,1585961214,1585441353,1585577145,1585947839,1609229336,1609226944,1589017730,1589791878,1609021392,1609337773,1612859899,1609313339,1590109680,1622512174,1609271320,1587393873,1587905815,1617876269,1621784692,1622547456,1590808197,1617097899,1606785927,1590263194,1604621524,1618091922,1618556499,1589951813,1590526708,1613993853,1592534526,1595017369,1595652771,1602157746,1595648044,1599966770,1604746259,1615224427,1600743314,1630246279,1599503159,1605800562,1673505842,1607478848,1624826137,1606455075,1626190649,1625697940,1628727661,1613167765,1610614471,1611091880,1610873808,1662181408,1624324566,1618261520,1615685219,1639061639,1639876120,1617090415,1616206651,1703829166,1619815344,1623702398,1620680377,1622745539,1640663494,1621006406,1644194356,1621532645,1624461398,1649619831,1626145206,1645832615,1624708954,1634308126,1629742771,1649837151,1632827645,1631675948,1633110851,1644654802,1633124904,1648123634,1646373340,1637062307,1634465178,1635833219,1665450601,1665802499,1665799946,1716971726,1636878230,1637158538,1638399691,1682884713,1637535305,1640944887,1638943717,1790687032,1640141642,1641654005,1643767056,1653388515,1647743983,1685208230,1647667885,1689226070,1646543430,1660580635,1646614994,1671408346,1666133434,1646804280,1666851329,1646320529,4188840796,1701079169,1711635617,1650455027,1653332108,1702895945,1681016072,1650469287,1650759043,1663583010,1650825671,1653763052,1680353887,1671221552,1654225932,1651549723,1654675842,1707797424,1747144232,1670477186,1670478684,1656294311,1664299326,1655846544,1654337778,1654580586,1696230039,1658713590,1657351973,1678239123,1657520788,1669057909,1664301736,1660593033,1664208002,1665602184,1666212570,1752293643,1753951037,1755039124,1777591618,1668525247,1669094305,1758899681,1673127249,1675441704,1673703524,1673713548,1673986749,1676259827,1680487429,1678566186,1680893310,1699428990,1740611873,1686932009,1821383659,1684970115,1791110792,1685759340,1689500687,1686546562,1687200670,1688553521,1690275043,1695447703,1691090213,1715689520,1691098723,1692772069,1692840377,1699341888,1695104082,1708518327,1698704933,1720663280,1790314270,1702367930,1699488190,1702753988,1905522025,1709771035,1734033605,1705132930,1704716880,1736162886,1708427812,1739339308,1711849673,1715103616,1712168437,1714208416,1713202109,1717270345,1715142566,1748190004,1748363914,1744655795,1720560682,1715363972,1762999309,1714898908,1715179182,1718378623,1774662915,1720475956,1720728523,1720123038,1717487596,1717473992,1717532186,1717967959,1801744448,1729306147,1743253647,1743250375,1720775257,1728625951,1733014456,1756489130,1733146313,1746140130,1759060668,1734960249,1742871090,1739685944,1762958840,1783513352,1735922800,1740221055,1740225583,1766921276,1766951545,1752659070,1755887706,1743497887,1746108907,1750786440,2407617441,2533306028,1747195640,1747748141,1774852320,1750346012,1750868352,1750979322,1756259224,1755190970,1782204004,1806786898,1778032012,1754019376,1753514740,1754832269,1790575833,1797062405,1755602099,1773844986,1775520089,1777959363,1757012866,1757234605,1961578219,1988371466,1757260759,1759925389,1788793674,1759906561,1759968821,1761043140,1760567160,1811804547,1811860140,1785987431,1763211293,1761028752,1763153408,1762680571,1840868043,1869056469,1764386392,1818698455,'
)
where id_ in (2,3)
;

-- only 2 and 3 get the third part
update test 
set col_ = col_||to_clob(
'1814925259,1844048107,1792923113,1766759279,1806690100,1769099790,1781889076,1767419994,1840873334,1860451690,1869057032,1832297539,1798732309,1777625741,1769504412,2256654733,2256394643,1769294952,1771550966,1773552097,1780825387,1775358335,1831495772,1777950912,1817575825,1778590238,1838491762,1842689273,1809036097,1842691008,1804226456,1778837913,1779109995,1802175163,1797361215,1782177386,1780300688,1783979889,1782182913,1782741969,1804421414,1784397327,1818168758,1786992906,1792081356,1792088712,1786004770,1790345572,1809433204,1815113504,1792147789,1789809441,1796047787,2052143664,1817107737,1817107064,1793983861,1794022214,1822817576,1811874533,1873343889,1866775899,1796519453,1811387402,1811390161,1811389686,1794329867,1798454338,1852540260,1875851020,1800774505,1821743703,1860623035,1821739977,1846153724,1889792452,1886966038,1800887081,3808566599,3940130288,3940136831,1798020921,1914756178,1801865643,1811249875,1799835543,1828917793,1802270135,1800012292,1800532265,1807895881,1812249070,1804106223,1825280927,1803288440,1803816935,1807255080,2018350809,2019138810,1851705279,1907325238,1871335841,1808765462,1809134665,1810437035,1813509873,1810547173,1811326813,1811694658,1824684930,1813787955,1839416942,1818235954,1895818608,1905958320,1830160706,1818228275,1842536407,1818806574,1836790621,1864363952,1817484177,1836665032,1836660198,1906067440,1901970936,1905622709,1818602143,1817971775,1821837825,1849836667,1868981787,1881234294,1881234637,1821288875,1833130648,1826325419,2973158753,1845549940,1830174632,1842407948,1830421553,1829985582,1893281403,1914874048,1889040775,1880361403,1921892126,1931315066,1827486462,1828963796,1829674270,1897254018,1915426413,1899844779,1932515087,1831848686,1831689960,1835308484,1838654429,1835519644,1849474090,1835786806,1908508982,1902791623,1870633645,1832944914,1892062861,1911322479,1871343608,1926558773,1848937114,1849426970,1836057852,1833236489,1833656603,1853711860,1833975396,1860757357,1838043540,1893303429,1893232952,1868373271,1889112786,1835184952,1835791195,1874018090,1871440216,1874342861,1839127975,1854395675,1839672686,3912799648,1932709261,1839473346,1850125810,1841465143,1843159279,1842576914,1843007201,1904067060,1888440163,1846360698,1858511426,1864065464,1874159628,1905554582,1904788564,1848619528,1852033506,1851154589,1855759701,1868417858,1855131342,1877691966,1880931070,1880908960,1861645053,1873708585,1873828632,1929998820,1864080430,1901401422,1898693844,1866675797,1881799571,1863363457,1879150302,1867310018,1913885364,1868061766,1901332941,1901333520,1884062883,1912162181,1867188977,1927263938,1941864872,1867081010,1897661727,1886785734,1868117499,1907251286,1870080439,1887027718,1929998928,1870956156,2150027360,2150307013,1874312074,1880967321,1901284503,1877295727,1911473147,1883166598,1899038584,1893959217,1916254122,1932517625,1893959339,1933595065,1945529144,1942281798,1887151883,1888450314,1894921531,1901818712,1894220580,1909749242,2065657174,1897279003,2060062735,1898400805,1903488534,1904890537,1918506617,1908422848,4457911809,1907237508,1905867088,1913081045,1925547868,1906306816,1909451800,1959470521,1907606907,1925323155,1912783604,1912782165,1909366720,1914761244,1918181121,1914430807,1947239893,1931601005,1913264338,1930650072,1951534568,1930896518,1920306065,1916196520,1916283047,1918255238,1931318996,1931322009,1937810611,1919069583,1927164440,1920305658,1924743213,1946095387,3609531133,3663324518,1931167839,1921962136,1922335417,1922555676,1923532923,1924064543,1930611475,1926184585,1926239192,1926608509,1935074989,1944611992,1932692433,1929319800,1931722999,1932762459,1955720668,1938674808,1939564345,1929449684,1931559090,1950526911,1945032610,1953285923,1935505180,1935753529,1951322279,1935890419,1949922533,1938628712,1950054253,1939514084,1941503687,1943021877,1953597488,1953598822,1942035546,1975810062,1972606764,1941750693,2047638895,1947964583,1975577308,1975577352,1972910374,1972907949,1944325055'
)
where id_ in (2,3)
;

-- only 3 gets the fourth part
update test 
set col_ = col_||to_clob(
',1948673740,1971775559,1959452762,1945820918,1946729992,1948575079,1949406069,1949679905,1951708200,1954659337,2082042164,1973102545,1958566705,1958952936,1962086871,1977320542,1979116386,1984862747,1979189193,1964417653,1976708450,1961770729,1975636620,1968687908,1963362914,1963763171,1968018287,1966719210,2035732281,2055743483,2057969213,2033792616,2053007679,2048122581,1985328064,1969517527,1969024053,1969576592,2187898958,1975517403,1975516319,1977454781,2015317801,1983863928,1975834633,2034294999,2033789600,1979630693,1984176587,1976224303,1990490329,1980772147,2002535750,2489429085,2466487161,2624118025,1981002029,1991863266,1978969289,2012332928,2012365221,1980271916,1982753982,1988228761,1996388928,1990132999,1990458049,1994361024,2017223549,1991726909,1994538500,2012416722,1995300364,2041752227,2041692794,2020875807,1996209164,1996939602,2050771629,2120682448,2000348494,2017919836,2044060252,2000995926,2114066128,2019696323,2005103030,2067148395,2086973457,2003237847,2014747711,2014747747,2018954778,2064226173,2005985054,2014745090,2008082621,2008923234,2010072867,2010514404,2012633060,2039487432,2033957571,2011105958,2011356502,2012736269,2023797663,2034716317,2017649667,2046271657,2689454239,2687105288,2015566644,2027000415,2064253365,2150994549,2099375825,2129560075,2088685497,2016356764,2053453035,2137424877,2100014838,2212083152,2019190552,2019587928,2060814646,2035277035,2023922773,2025007411,2023121822,2026183446,2033549022,2033549052,2055844770,2084427654,2132364379,2108982590,2091656086,2128930838,2116160694,2132361804,2060062678,2035464746,2043640105,2051363476,2045095315,2045355332,2063885164,2046028617,2054661478,2054494010,2048955702,2192802668,2051362845,2057485949,2051364001,2055840260,2051508935,2052590429,2053762179,2052638545,2065638248,2054382409,2054743095,2062269348,2123546644,2125309150,2058818717,2062669598,2066199863,2068830772,2058819844,2056415551,2056608519,2062671380,2058845909,2057221018,2081772205,2060801722,2061287659,2062478863,2066834800,2085488979,2064477479,2066002357,2065065221,2168514653,2203033983,2141245124,2169567082,2080009171,2068723579,2067490582,2084130020,2084130041,2084130066,2109140465,2199630590,2084131233,2084131276,2084131326,2107658933,2074223820,2074223858,2074223903,2199631814,2084133411,2084133432,2084133457,2192930335,2199632895,2192805746,2084136222,2084136318,2084136482,2199633582,2199633363,2084141353,2084141416,2084141492,2072716211,2081963645,2081883280,2127800693,2079921865,2072801933,2073017433,2084148071,2084148205,2088119398,2087106943,2084144453,2084144474,2084144499,2079061390,2079347114,2079968745,2146668286,2146720057,2297343041,2289861797,2137127785,2137121986,2131246609,2168522731,2218105811,2169572607,2141215656,2080595509,2084102284,2334599325,2437306692,2449266675,2431717448,2084447495,2082824852,2168493321,2169570405,2141985628,2189948559,2083538125,2466561164,2719142737,2945921676,3141825913,3292002088,3291653688,2084056119,2567604300,2567807805,2085081472,2085110990,2085132590,2085229311,2085608972,2100508561,2089673053,2127808443,2087766197,2192807025,2088356868,2089076140,2090607399,2090338279,2163837715,2131555978,2210750346,2210774623,2092594582,2092808908,2131280988,2133657963,2122292999,2122300646,2107657219,2108078603,2108206990,2174341948,2235097046,2131258221,2200615407,2224986097,2188144771,2108807285,2155972957,2174601176,2114709209,2294935903,2375448272,2115353212,2319356727,2387339621,2123534389,2116848461,2195339379,2136070544,2169319257,2125885978,2172755624,2116334790,2119033720,2118935563,2118714846,2183651152,2155653835,2118275049,2118299232,2123759318,2233083654,2457607783,2543502171,2517621550,2526399862,2554622538,2603515279,2137005760,2120012384,2159107796,2119478209,2146711869,2123529070,2142543363,2142610303,2120746892,2124046700,2121433481,2121498379,2121554906,2142696324,2124821808,2135745772,2122258033,2122378374,2122384636,2279973128,2123742601,2134364783,2131247889,2155250364'
)
where id_ in (3)
;

-- only 3 gets the last part
update test 
set col_ = col_||to_clob(
',1948673740,1971775559,1959452762,1945820918,1946729992,1948575079,1949406069,1949679905,1951708200,1954659337,2082042164,1973102545,1958566705,1958952936,1962086871,1977320542,1979116386,1984862747,1979189193,1964417653,1976708450,1961770729,1975636620,1968687908,1963362914,1963763171,1968018287,1966719210,2035732281,2055743483,2057969213,2033792616,2053007679,2048122581,1985328064,1969517527,1969024053,1969576592,2187898958,1975517403,1975516319,1977454781,2015317801,1983863928,1975834633,2034294999,2033789600,1979630693,1984176587,1976224303,1990490329,1980772147,2002535750,2489429085,2466487161,2624118025,1981002029,1991863266,1978969289,2012332928,2012365221,1980271916,1982753982,1988228761,1996388928,1990132999,1990458049,1994361024,2017223549,1991726909,1994538500,2012416722,1995300364,2041752227,2041692794,2020875807,1996209164,1996939602,2050771629,2120682448,2000348494,2017919836,2044060252,2000995926,2114066128,2019696323,2005103030,2067148395,2086973457,2003237847,2014747711,2014747747,2018954778,2064226173,2005985054,2014745090,2008082621,2008923234,2010072867,2010514404,2012633060,2039487432,2033957571,2011105958,2011356502,2012736269,2023797663,2034716317,2017649667,2046271657,2689454239,2687105288,2015566644,2027000415,2064253365,2150994549,2099375825,2129560075,2088685497,2016356764,2053453035,2137424877,2100014838,2212083152,2019190552,2019587928,2060814646,2035277035,2023922773,2025007411,2023121822,2026183446,2033549022,2033549052,2055844770,2084427654,2132364379,2108982590,2091656086,2128930838,2116160694,2132361804,2060062678,2035464746,2043640105,2051363476,2045095315,2045355332,2063885164,2046028617,2054661478,2054494010,2048955702,2192802668,2051362845,2057485949,2051364001,2055840260,2051508935,2052590429,2053762179,2052638545,2065638248,2054382409,2054743095,2062269348,2123546644,2125309150,2058818717,2062669598,2066199863,2068830772,2058819844,2056415551,2056608519,2062671380,2058845909,2057221018,2081772205,2060801722,2061287659,2062478863,2066834800,2085488979,2064477479,2066002357,2065065221,2168514653,2203033983,2141245124,2169567082,2080009171,2068723579,2067490582,2084130020,2084130041,2084130066,2109140465,2199630590,2084131233,2084131276,2084131326,2107658933,2074223820,2074223858,2074223903,2199631814,2084133411,2084133432,2084133457,2192930335,2199632895,2192805746,2084136222,2084136318,2084136482,2199633582,2199633363,2084141353,2084141416,2084141492,2072716211,2081963645,2081883280,2127800693,2079921865,2072801933,2073017433,2084148071,2084148205,2088119398,2087106943,2084144453,2084144474,2084144499,2079061390,2079347114,2079968745,2146668286,2146720057,2297343041,2289861797,2137127785,2137121986,2131246609,2168522731,2218105811,2169572607,2141215656,2080595509,2084102284,2334599325,2437306692,2449266675,2431717448,2084447495,2082824852,2168493321,2169570405,2141985628,2189948559,2083538125,2466561164,2719142737,2945921676,3141825913,3292002088,3291653688,2084056119,2567604300,2567807805,2085081472,2085110990,2085132590,2085229311,2085608972,2100508561,2089673053,2127808443,2087766197,2192807025,2088356868,2089076140,2090607399,2090338279,2163837715,2131555978,2210750346,2210774623,2092594582,2092808908,2131280988,2133657963,2122292999,2122300646,2107657219,2108078603,2108206990,2174341948,2235097046,2131258221,2200615407,2224986097,2188144771,2108807285,2155972957,2174601176,2114709209,2294935903,2375448272,2115353212,2319356727,2387339621,2123534389,2116848461,2195339379,2136070544,2169319257,2125885978,2172755624,2116334790,2119033720,2118935563,2118714846,2183651152,2155653835,2118275049,2118299232,2123759318,2233083654,2457607783,2543502171,2517621550,2526399862,2554622538,2603515279,2137005760,2120012384,2159107796,2119478209,2146711869,2123529070,2142543363,2142610303,2120746892,2124046700,2121433481,2121498379,2121554906,2142696324,2124821808,2135745772,2122258033,2122378374,2122384636,2279973128,2123742601,2134364783,2131247889,2155250364'
)
where id_ in (3)
;

select length(col_),id_ from test;
-- LENGTH(COL_) ID_
--  3965          1
-- 11885          2
-- 19805          3

select * from test
        where col_ like 'step A: 1514 JBPM_TASKINSTANCE cancelled. IDs%';
-- 3 results

select * from test
            where col_ like 'step A: % JBPM_TASKINSTANCE cancelled. IDs%';
-- (!!!) 2 results

1 个答案:

答案 0 :(得分:1)

具有通配符(%)的赞不适用于4000char + clob列

TRUE (适用于11G)

(适用于12c及以上)

对于11g,您可以使用以下查询满足您的要求:

select * from test
            where dbms_lob.instr(col_,' JBPM_TASKINSTANCE cancelled. IDs') > dbms_lob.instr(col_,'step A: ');

Demo

POC:

11G:Error with 11G - Demo

18C / 12C:Working as expected - Demo