Home > Database > Mysql Tutorial > body text

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

王林
Release: 2023-09-06 14:53:02
forward
906 people have browsed it

我们如何在没有任何列列表的情况下创建 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)
Copy after login

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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template