1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
DELETE Statements
You can delete from a join view provided there is one and only one
key-preserved table in the join.
The key-preserved table can be repeated in the FROM clause.
The following DELETE statement works on the emp_dept view:
DELETE FROM emp_dept WHERE ename = 'SMITH';
This DELETE statement on the emp_dept view is legal
because it can be translated to a DELETE operation on the base emp table,
and because the emp table is the only key-preserved table in the join.
In the following view, a DELETE operation is permitted,
because although there are two key-preserved tables,
they are the same table.
That is, the key-preserved table is repeated.
In this case, the delete statement operates on the first table in the FROM list (e1, in this example):
CREATE VIEW emp_emp AS SELECT e1.ename, e2.empno, e2.deptno
FROM emp e1, emp e2 WHERE e1.empno = e2.empno; |
Partager