Examples of MySQL RENAME VIEW
Let’s take an example of the EMPLOYEE table having EMP_ID, NAME, AGE, and SALARY as columns.
CREATE TABLE EMPLOYEE (
EMP_ID INT PRIMARY KEY,
NAME VARCHAR(50),
AGE INT,
SALARY INT
);
Insert the data on it:
INSERT INTO EMPLOYEE (EMP_ID, NAME, AGE, SALARY) VALUES
(1, 'Sahil', 21, 15000),
(2, 'Alen', 22, 13000),
(3, 'John', 22, 14000),
(4, 'Alex', 20, 13000),
(5, 'Mathew', 22, 14000),
(6, 'Sia', 21, 15000),
(7, 'David', 22, 16000),
(8, 'Tim', 21, 14000),
(9, 'Leo', 20, 15000),
(10, 'Tom', 21, 16000);
EMPLOYEE Table:
Now Let’s CREATE 2 VIEWS from the EMPLOYEE Table.
Query:
CREATE VIEW view1 AS
SELECT EMP_ID, SALARY
FROM EMPLOYEE;
CREATE VIEW view2 AS
SELECT EMP_ID, AGE, SALARY
FROM EMPLOYEE
WHERE SALARY=14000;
Output: view1
view2:
MySQL – Rename View
MySQL is a popular open-source relational database management system (RDBMS) that is usually used for developing scalable and high-performance databases. MySQL was developed by MySQL AB (currently owned by Oracle Corporation) in 1995. MySQL is known for its robust, easy, and reliable features with quick processing speeds. MySQL is generally used by dynamic web applications and is commonly used by languages such as PHP, Python, and other server-side programming languages.
In this article, you will learn how to RENAME a view in MySQL along with some examples.