• 登录
  • Subscribe RSS Feed
 

'Update' Tag

  • update的一次教训

    08月 9, 2009

            在一次update过程中(根据一张表的记录更新另一张表上对于记录的字段),原计划是更新满足一定条件的记录,结果更新结果的记录数为整张表的记录。回滚后,看了一下语句,update tab_1  set tab1_col1 = (select tab2_col1 from tab_2 where tab_1.id = tab_2.id),没有加上where语句,导致连接中匹配不到的记录更新为NULL。 SQL> select * from dept; DEPTNO DNAME LOC ---------- -------------- ------------- 10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON SQL> select * from abc; DEPTNO DNAME ---------- -------------- 10 test 20 test 30 test 40 test [...]

 
Powered by BlogCN.com - WordPress and MySQL. Theme by Shlomi Noach, openark.org