如何重命名 MySQL 中的视图?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5475473/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to rename a view in MySQL?
提问by vincy
I have created a view vw_extr
.
我创建了一个视图vw_extr
。
Now I want to rename it vw_my
.
现在我想重命名它vw_my
。
How can a view be renamed in MySQL?
如何在 MySQL 中重命名视图?
回答by Ike Walker
You can use RENAME TABLE
for that:
你可以使用RENAME TABLE
:
RENAME TABLE vw_extr to vw_my
回答by Alfredo Herrejon
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
.
停止 MySQL,切换到我的数据库目录,然后重命名my_old_view.frm
为my_new_view.frm
.
I was using linux, so the commands were:
我使用的是 linux,所以命令是:
/etc/init.d/mysqld stop
cd /var/lib/mysq/DatabaseName
mv my_old_view.frm my_new_view.frm
/etc/init.d/mysqld start
回答by Saravanan Andavar
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://docs.microsoft.com/en-us/sql/relational-databases/views/views?view=sql-server-ver15
View 不提供将其像 table 一样重命名为虚拟表的选项。每当我们创建alter时,MS SQL Server都会重新编译。请参考附件网址。 https://docs.microsoft.com/en-us/sql/relational-databases/views/views?view=sql-server-ver15
回答by Brian Driscoll
DROP VIEW IF EXISTS vw_extr;
DROP VIEW IF EXISTS vw_extr;
CREATE VIEW vw_my ...
CREATE VIEW vw_my ...
You'll have to fill my ...
with your view's DDL.
你必须...
用你的视图的 DDL来填充我的。