日期:2014-05-17 浏览次数:21039 次
SQL> update ( 2 select e.sal as emp_sal,e.comm as emp_comm, 3 ns.sal as ns_sal, ns.sal/2 as ns_comm 4 from emp e,new_sal ns 5 where e.deptno=ns.deptno 6 )set emp_sal=ns_sal,emp_comm=ns_comm; )set emp_sal=ns_sal,emp_comm=ns_comm * 第 6 行出现错误: ORA-01779: 无法修改与非键值保存表对应的列 SQL> select * from emp; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ----- ---------- --------- ----- ------------ --------- --------- ------ 7369 SMITH CLERK 7902 17-12月-80 1056.00 20 7499 ALLEN SALESMAN 7698 20-2月 -81 1600.00 300.00 30 7521 WARD SALESMAN 7698 22-2月 -81 1250.00 500.00 30 7566 JONES MANAGER 7839 02-4月 -81 3272.50 20 7654 MARTIN SALESMAN 7698 28-9月 -81 1250.00 1400.00 30 7698 BLAKE MANAGER 7839 01-5月 -81 2850.00 30 7782 CLARK MANAGER 7839 09-6月 -81 2450.00 10 7788 SCOTT ANALYST 7566 19-4月 -87 3960.00 20 7839 KING PRESIDENT 17-11月-81 5000.00 10 7844 TURNER SALESMAN 7698 08-9月 -81 1500.00 .00 30 7876 ADAMS CLERK 7788 23-5月 -87 1210.00 20 EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ----- ---------- --------- ----- ------------ --------- --------- ------ 7900 JAMES CLERK 7698 03-12月-81 1140.00 30 7902 FORD ANALYST 7566 03-12月-81 3300.00 20 7934 MILLER CLERK 7782 23-1月 -82 1560.00 10 1111 YOUDA JEDI 17-11月-81 5000.00 1 JONATHAN EDITOR SQL> select * from new_sal; SAL DEPTNO --------- ------ 4000.00 10 请大侠帮忙看看,我是菜鸟希望能说详细点。
alter table new_sal add constraintpk_new_sal primary key (deptno);