SQL:将count与Clob一起使用
我有一个表feature_vector,它有两列doc_id和feature_vector,其中feature_vector是一个包含字符串的SQL:将count与Clob一起使用,sql,oracle,count,clob,Sql,Oracle,Count,Clob,我有一个表feature_vector,它有两列doc_id和feature_vector,其中feature_vector是一个包含字符串的CLOB 由于同一个doc_id可能有多个feature_向量值,因此我尝试使用以下方法获取计数: select doc_id, count(feature_vector) from feature_vector_t group by doc_id 然而,我有一个错误,说 ORA--00932不一致的数据类型:应为got CLOB 93200000-“不
CLOB
由于同一个doc_id可能有多个feature_向量值,因此我尝试使用以下方法获取计数:
select doc_id, count(feature_vector) from feature_vector_t group by doc_id
然而,我有一个错误,说
ORA--00932不一致的数据类型:应为got CLOB
93200000-“不一致的数据类型:应为%s获得%s”
另一个查询通过将Clob转换为字符串来工作
select doc_id, count(dbms_lob.substr(feature_vector, 1, 5)) from feature_vector_t group by doc_id
有人能解释一下幕后发生了什么吗?为什么计数不能与原始clob一起工作?Oracle似乎有一个限制,不允许您将LOB传递给
count()
函数
但是,出于性能原因,您不希望计算LOB。如果feature\u vector
从不为空,则
select doc_id, count(*) from feature_vector_t group by doc_id
应该足够了,否则您可以使用以下内容:
select
doc_id,
count(case when feature_vector is null then null else 1 end)
from feature_vector_t group by doc_id
能否附上这两种情况的说明计划?