这个问题比较简单,可是有性能要求. 现在数据库里有一个表,表里有两个字段,如下: 
表名:File_Name_Table 
字段:ID 
     File_Name
这个表大概有一百五十万条记录。我现在程序里有一个文件名列表,列表里大概有五十个文件名字符串, 
我想分别判断列表里的文件名在数据库的表里存不存在, 要用一种最快的方法来实现,请大家给点参考意见.多谢了!

解决方案 »

  1.   

    filename 字段建索引,然后把文件名导到临时表temp里,然后
    select filename from temp
    minus
    select filename from table;

    select filename from temp a 
    where not exists 
    (select '1' from table b where a.filename=b.filename);
    得出来的就是数据库里没有的。
    select filename from temp a 
    where exists 
    (select '1' from table b where a.filename=b.filename);
    得出来的就是数据库里有的
      

  2.   

    你只有两个字段,不需要建索引,
    select * from File_Name_Table where File_Name like'%表的单词%'