Examples of MySQL Rename View

Example 1: Renaming view1 using RENAME keyword

Let RENAME view1 to employee_details1.

Syntax:

RENAME TABLE old_view_name TO new_view_name;

Query:

RENAME TABLE view1 TO employee_details1;

Output:

successfully renamed

Explanation: In the above example we are renaming view1 to employee_details1. In the output we can see that there are 0 rows affected, this is because renaming a view will not change the underlying data in the table.

Example 2: Renaming view2 using RENAME keyword

Lets RENAME view2 to employee_details2

Syntax:

RENAME TABLE old_view_name TO new_view_name;

Query:

RENAME TABLE view1 TO employee_details1;

Output:

successfully renamed

Explanation: In the above example we are renaming view2 to employee_details2. In the output we can see that there are 0 rows affected, this is because renaming a view will not change the underlying data in the table.

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.

Similar Reads

MySQL – Rename View

In relational database management systems (RDBMS) like MySQL, a VIEW is a virtual table interactive with data generated from one or more underlying tables through either a defined query. Unlike a regular table, the VIEW as a query doesn’t store the data itself. Instead, it creates a result set when someone queries it. MySQL provides a feature to RENAME an Existing VIEW. Renaming a VIEW in MySQL will not change the data in the underlying tables it will only change the name by which the view is referenced in SQL queries and the database schema....

Examples of MySQL RENAME VIEW

Let’s take an example of the EMPLOYEE table having EMP_ID, NAME, AGE, and SALARY as columns....

Examples of MySQL Rename View

Example 1: Renaming view1 using RENAME keyword...

Conclusion

In conclusion, MySQL allows you to RENAME an existing VIEW. It is a metric that is quite essential in cases where you need to make sure that each naming convention is consistent or helps improve the clarity of the database structure. Be reminded that the renaming of a VIEW does not change the underlying data but rather it does modify only the name by which the view is referenced. Moreover, you should be caring about any occurrence of the dependencies on the VIEW, for instance, stored routines or other views, thus, such dependencies will be updated after the renaming has been fulfilled....