SQL> create table table_list
2 as select * from dba_tables
3 /
Table created.
SQL> create view view1
2 as select * from table_list
3 /
View created.
SQL> update view1 set owner = 'ANDREW'
2 /
3063 rows updated.
SQL> select owner, count(*) from table_list
2 group by owner
3 /
OWNER COUNT(*)
------------------------------ ----------
ANDREW 3063
SQL> delete table_list
2 /
3063 rows deleted.
SQL> insert into table_list
2 select * from dba_tables
3 /
3064 rows created.
SQL>
However, view2 includes a group by statement. Each row in this view has data collected from one or more rows in the base table. If you try to update it, Oracle has no idea how to carry any changes through to the base table so it generates an error message:
SQL> create view view2
2 as select owner, count(*) number_present
3 from table_list
4 group by owner
5 /
View created.
SQL> update view2 set number_present = 0
2 /
update view2 set number_present = 0
*
ERROR at line 1:
ORA-01732: data manipulation operation not legal on
this view
SQL>
No comments:
Post a Comment