1. 程式人生 > >oracle資料庫:update更新多表總結

oracle資料庫:update更新多表總結

5) 關聯update的一個特例以及效能再探討
在oracle的
update語句語法中,除了可以update表之外,也可以是檢視,所以有以下1個特例:

SQL 程式碼
  1. update (select a.city_name,b.city_name as new_name
  2. from customers a,
  3. tmp_cust_city b
  4. where b.customer_id=a.customer_id
  5. )
  6. set city_name=new_name

這樣能避免對B表或其索引的2次掃描,但前提是 A(customer_id) b(customer_id)必需是unique index或primary key