A表2个字段 a1,a2
B表2个字段 b1,b2,b3A表(大约600万数据)记录:
a1    a2
100   null
237   null
166   null
...B表(大约10万数据)记录:
b1    b2    b3
0     150   AA
200   300   BB
153   188   CC
...执行SQL:
update A set a2=(select b3 from B where A.a1 between B.b1 and B.b2);数据量很大,这种update如何建索引

解决方案 »

  1.   

    update 建立索引干什么??update建立索引,只会让update运行更慢,不建立索引是最好的。
      

  2.   

    update也可以用索引呀。两个表数据量这么大,不走索引得跑多长时间呀
      

  3.   

    update A set a2=(select b3 from B where A.a1 between B.b1 and B.b2);
    这条语句执行中可能会发生错误吧?当在表B中存在两条或更多符合a.a1 between b.b1 and b.b2的数据时会出错的,建议楼主采用更严谨的语句。