在Oracle表中搜索 [英] Search in a Oracle Table
本文介绍了在Oracle表中搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
我确实有一个搜索字符串,并且需要显示与来自特定Oracle DataTable的搜索字符串相似的词.
我能够做到,但是由于搜索是通过整个
进行的
DataTable非常耗时,因此会导致性能问题.
请建议我该怎么做...
Hi Folks,
I do have a search string, and I need to display the words similar to that search string from a particular Oracle DataTable.
I am able to do that but since the search is through the entire
DataTable it''s time consuming, thus creating a performance issue.
Please suggest how do I go for it...
推荐答案
如果仅在一个字段中进行搜索,只需使用标准的SQL命令:
If you are searching only in one field, just use standard SQL command:
SELECT myfield FROM mytable WHERE criteria=searchstring;
如果要搜索整行,请尝试以下操作:
If you are searching on the whole row, try this:
using System.Data;
using System.Linq;
// this is for single result, would return null if no result
DataRow result = (from DataRow r in tableVariable.Rows
where string.Join(",", r.ItemArray).Contains(searchString)
select r).FirstOrDefault();
// and this is for many result
List<DataRow> results = (from DataRow r in tableVariable.Rows
where string.Join(",", r.ItemArray).Contains(searchString)
select r).ToList();
虽然还没有尝试过,但是我认为这是一种快速有效的方法(不耗时).
Haven''t tried it though, but I think it is an fast and effective way (not time-consuming).
这篇关于在Oracle表中搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文