qq_ forty-five million eight hundred and forty-nine thousand tw 2022-02-13 05:09:20 阅读数:267
– Create a simple view
create view view_owners1 as
select * from t_owners where ownertypeid=1
– Query simple view
select * from view_owners1 where addressid=1
– Modify view data
update view_owners1 set name=‘ Fan Xiaobing ’ where id=1;
commit;
select * from t_owners
– View with check constraint
create view view_address2 as
select * from t_address where areaid=2
with check option
– The successful statement cannot be modified , Because the condition of this view is areaid=2
update view_address2 set areaid=3 where id=4
– Read only view
create or replace view view_owners1 as
select * from t_owners where ownertypeid=1
with read only
– Modify read-only view data
update view_owners1 set name=‘ Fan Dabing ’ where id=1;
– Create a view with errors
create force view view_test as
select * from t_test
– Complex view - More than a table
create or replace view view_owners as
select ow.id Owner number ,ow.name Name of employer ,ot.name Type of owner from t_owners ow,t_ownertype ot
where ow.ownertypeid=ot.id
– Query complex views ( More than a table )
select * from view_owners where Type of owner =‘ Resident ’;
– Modify complex views ( More than a table ) The data of
update view_owners set Name of employer =‘ Lin Lingling ’ where Owner number =4
update view_owners set Type of owner =‘ business ’ where Owner number =4
– Key retention table : The table that retains the primary key
– A complex view of aggregate statistics
create view view_accountsum as
select year,month,sum(money) money
from t_account
group by year,month
order by year,month
select * from view_accountsum where year=‘2012’ and month=‘03’
– Can you modify it ?– answer : Cannot .
update view_accountsum set month=‘04’ where year=‘2012’ and month=‘03’
copyright:author[qq_ forty-five million eight hundred and forty-nine thousand tw],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/02/202202130509177901.html