Home >Database >Mysql Tutorial >How can we create a MySQL view without any column list?

How can we create a MySQL view without any column list?

王林
王林forward
2023-09-06 14:53:02932browse

我们如何在没有任何列列表的情况下创建 MySQL 视图?

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete