mysql create view only if it doesn't already exist

喜你入骨 提交于 2019-12-07 01:52:02

问题


How do I create a view only if it doesn't exist. If it does exist, I want to drop the view and redefine it. I also want no warnings or errors.


回答1:


You're going to kick yourself:

CREATE OR REPLACE VIEW ...

Details here. ;-)




回答2:


CREATE OR REPLACE VIEW <view name>
AS
<your select expression goes here>


来源:https://stackoverflow.com/questions/2245847/mysql-create-view-only-if-it-doesnt-already-exist

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!