Home > Database > Mysql Tutorial > How can we get the definition of a MySQL view the same way we get the definition of a MySQL table?

How can we get the definition of a MySQL view the same way we get the definition of a MySQL table?

王林
Release: 2023-09-07 11:49:05
forward
809 people have browsed it

How can we get the definition of a MySQL view the same way we get the definition of a MySQL table?

We know that a view is a virtual table and a combination of tables, so we can use the same query to get the definition of the view, and then use the definition of the view to get the view The definition of a table. In other words, we can use the SHOW CREATE statement to get the definition of a MySQL view. Its syntax is as follows -

Syntax

SHOW CREATE VIEW view_name;
Copy after login

Here view_name is the name of the view whose definition we want to get.

Example

The following query will give a view defined named "info" -

mysql> Show Create View Info\G
*************************** 1. row ***************************
                View: info
         Create View: CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `info` AS select `student_info`.`id` AS `ID`,`student_info`.`Name` AS `NAME`,`student_info`.`Subject` AS `SUBJECT`,`student_info`.`Address` AS `ADDRESS` from `student_info`
character_set_client: cp850
collation_connection: cp850_general_ci

1 row in set (0.00 sec)
Copy after login

The above is the detailed content of How can we get the definition of a MySQL view the same way we get the definition of a MySQL table?. 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