我们如何基于另一个现有视图创建MySQL视图?
在MySQL中,我们可以创建基于另一个现有视图的视图。为了使其理解,我们使用以下数据查看“信息”-
mysql> Create view info AS Select Id, Name, Subject FROM student_info; mysql> Select * from Info; +------+---------+------------+ | Id | Name | Subject | +------+---------+------------+ | 101 | YashPal | History | | 105 | Gaurav | Literature | | 125 | Raman | Computers | | NULL | Ram | Computers | +------+---------+------------+ 4 rows in set (0.00 sec)
现在,借助以下查询,我们正在基于现有视图“info”创建另一个视图名称“info_less”-
mysql> Create view info_less AS Select Id, Name, Subject FROM info WHERE id >= 120; mysql> Select * from info_less; +------+-------+-----------+ | Id | Name | Subject | +------+-------+-----------+ | 125 | Raman | Computers | +------+-------+-----------+ 1 row in set (0.03 sec)