What are the prerequisites before starting writing and using MySQL views?


MySQL Version

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)

Privileges for current user

Actually CREATE VIEW statement requires the CREATE VIEW privilege. Privileges for the current user can be checked with the following query −

mysql> SHOW PRIVILEGES

Selecting a database

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’.

Updated on: 22-Jun-2020

151 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements