We know that MySQL 5 introduces views, so before we start writing, we first need to check the version of MySQL and use stored procedures. This can be done through the following query -
mysql> Select VERSION(); +-----------+ | VERSION() | +-----------+ | 5.7.20 | +-----------+ 1 row in set (0.10 sec)
In fact, the CREATE VIEW statement requires CREATE VIEW permissions. The permissions of the current user can be checked using the following query -
mysql> SHOW PRIVILEGES
Before creating the view, we have to select a database from the available databases. This can be done with the help of the following query -
mysql> USE query; Database changed
From the above query, it is obvious that we are using the database named "query".
The above is the detailed content of What are the prerequisites before starting to write and use MySQL views?. For more information, please follow other related articles on the PHP Chinese website!