开发者

How to rename a view in MySQL?

I have created a view vw_extr. 开发者_如何学C

Now I want to rename it vw_my.

How can a view be renamed in MySQL?


You can use RENAME TABLE for that:

RENAME TABLE vw_extr to vw_my


DROP VIEW IF EXISTS vw_extr;

CREATE VIEW vw_my ...

You'll have to fill my ... with your view's DDL.


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


View doesn't provide options to rename it like table as its a virtual table. MS SQL Server recompile when ever we create alter. Please refer attached URL. https://learn.microsoft.com/en-us/sql/relational-databases/views/views?view=sql-server-ver15

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜