我们如何创建基于另一个现有视图的 MySQL 视图?
在 MySQL 中,我们能够创建基于另一个现有视图的视图。为了理解这一点,我们使用以下数据具有视图信息——
mysql> Create view info AS Select Id, Name, Subject FROM student_info; Query OK, 0 rows affected (0.11 sec) 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_less”的视图,该视图基于现有视图信息——
mysql> Create view info_less AS Select Id, Name, Subject FROM info WHERE id >= 120; Query OK, 0 rows affected (0.25 sec) mysql> Select * from info_less; +------+-------+-----------+ | Id | Name | Subject | +------+-------+-----------+ | 125 | Raman | Computers | +------+-------+-----------+ 1 row in set (0.03 sec)
广告