I have created a view vw_extr
.
Now I want to rename it vw_my
.
How can a view be renamed in MySQL?
In MySQL, views and tables share the same namespace. Therefore, you can use the RENAME TABLE statement to rename a view.
Using SQL Server Management Studio In Object Explorer, expand the database that contains the view you wish to rename and then expand the View folder. Right-click the view you wish to rename and select Rename. Enter the view's new name.
Use the Alter View statement to edit a view. Simply use the existing SQL Statement in the current view, and add the column to the end. A view can only display data from an existing table. You would have to add the column to the table and then modify the view to show it as well.
To rename the name of a view you follow these steps: First, in Object Explorer, expand the Databases, choose the database name which contains the view that you want to rename and expand the Views folder. Second, right-click the view that you want to rename and select Rename. Third, enter the new name for the view.
In MySQL, views and tables share the same namespace. Therefore, you can use the RENAME TABLE statement to rename a view. Here’s the basic syntax of the RENAME TABLE for renaming a view: RENAME TABLE original_view_name TO new_view_name;
The MySQL ALTER VIEW statement changes the definition of an existing view. The syntax of the ALTER VIEW is similar to the CREATE VIEW statement: ALTER [ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}] VIEW view_name [ (column_list)] AS select_statement;
The MySQL ALTER VIEW statement changes the definition of an existing view. The syntax of the ALTER VIEW is similar to the CREATE VIEW statement: See the following tables orders and orderdetails from the sample database.
Summary: in this tutorial, you will learn how to use the MySQL DROP VIEW statement to delete a view from the database. The DROP VIEW statement deletes a view completely from the database.
You can use RENAME TABLE
for that:
RENAME TABLE vw_extr to vw_my
Rename didn't work for me, what I did was:
Stop MySQL, change to my database directory, and rename from my_old_view.frm
to my_new_view.frm
.
I was using linux, so the commands were:
/etc/init.d/mysqld stop cd /var/lib/mysq/DatabaseName mv my_old_view.frm my_new_view.frm /etc/init.d/mysqld start
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With