View
By using views, we can string together items to be used from multiple tables into a virtual table. Calling the virtual table can simplify the complexity of statements.
CREATE VIEW view Create view
DROP VIEW view Drop view
If you need to update a view, you can delete it first and then create it anew, or use CREATE OR REPLACE VIEW view to update it. The statement means if a view with the same name exists, overwrite it; otherwise, create a virtual table.
When using views, we should avoid creating too many view joins. When using multiple view joins, we need to test the running time.
code:

1
2
3
4
5
6
7
8
9
drop view generalview;
create view generalview as
select p1.aeu_name,p2.geu_name,p3.sgeu_name,p3.sgeu_id
from allerrorunits as p1,generalerrorunits as p2,subgeneralerrorunits as p3
where p1.aeu_id = p2.geu_aeu_id and p2.geu_id = p3.sgeu_geu_id;

select *
from generalview
where sgeu_id=10103;

Typically found an error when calling subgeneralerrorunits.sgeu_id today, my brain wasn’t working at that time.
At this point, our view is a virtual table. If we still use the previous index, a column not found error will occur. Inputting the corresponding name directly (as shown in the table below) will allow normal operation.
Image Description