When creating a view, providing a column list is optional. The following example will be illustrated by creating a view without any column list -
mysql> Select * from student_detail; +-----------+-------------+------------+ | Studentid | StudentName | address | +-----------+-------------+------------+ | 100 | Gaurav | Delhi | | 101 | Raman | Shimla | | 103 | Rahul | Jaipur | | 104 | Ram | Chandigarh | | 105 | Mohan | Chandigarh | +-----------+-------------+------------+ 5 rows in set (0.17 sec) mysql> Create view View_student_detail AS SELECT * FROM Student_Detail; Query OK, 0 rows affected (0.17 sec)
As we have noticed in the below query, while creating the view we are not giving any column name that's why it is View without column list. Now, if we run the query using the name of the view, then we will get all the columns from the table where the view was created.
mysql> Select * from View_student_detail; +-----------+-------------+------------+ | Studentid | StudentName | address | +-----------+-------------+------------+ | 100 | Gaurav | Delhi | | 101 | Raman | Shimla | | 103 | Rahul | Jaipur | | 104 | Ram | Chandigarh | | 105 | Mohan | Chandigarh | +-----------+-------------+------------+ 5 rows in set (0.00 sec)
The above is the detailed content of How can we create a MySQL view without any column list?. For more information, please follow other related articles on the PHP Chinese website!