As we know that MySQL 5 introduced views, hence, first of all, we need to check for the version of MySQL before starting writing and using stored procedures. It can be done with the following query −
mysql> Select VERSION(); +-----------+ | VERSION() | +-----------+ | 5.7.20 | +-----------+ 1 row in set (0.10 sec)
Actually CREATE VIEW statement requires the CREATE VIEW privilege. Privileges for the current user can be checked with the following query −
mysql> SHOW PRIVILEGES
Before creating a view we must have to select a database from the available databases. It can be done with the help of the following query −
mysql> USE query; Database changed
From the above query, it is clear that we are using a database named ‘query’.