在MySQL中,我們可以創(chuàng)建一個基于另一個現(xiàn)有視圖的視圖。為了讓它理解,我們有一個名為’Info’的視圖,其中包含以下數(shù)據(jù)-
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)
登錄后復制
現(xiàn)在,通過以下查詢,我們正在創(chuàng)建一個名為’info_less’的新視圖,該視圖基于現(xiàn)有視圖’info’ –
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)
登錄后復制
以上就是我們?nèi)绾位诹硪粋€現(xiàn)有視圖創(chuàng)建 MySQL 視圖?的詳細內(nèi)容,更多請關注www.92cms.cn其它相關文章!