首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在phpMyAdmin中更新视图?

如何在phpMyAdmin中更新视图?
EN

Stack Overflow用户
提问于 2013-03-01 19:10:51
回答 5查看 30.8K关注 0票数 9

如何使用phpMyAdmin更新(或编辑) MySQL数据库中的视图。

我得到了一个由两个表中的列组成的视图-我在其中一个表中添加了一个新列,但视图中没有它。我找不到用于获取该视图的MySQL查询(它相当模糊)-那么如何编辑创建该视图的MySQL查询以向其中添加新列呢?

EN

回答 5

Stack Overflow用户

回答已采纳

发布于 2013-03-01 19:18:34

如何使用(您的视图称为viewname)

  1. SHOW CREATE VIEW viewname获取视图的SQL原样为
  2. DROP VIEW viewname删除视图
  3. 修改第一步中的SQL将新列添加到该SQL
  4. 运行modified SQL

这将创建包含附加列的视图

http://dev.mysql.com/doc/refman/5.0/en/show-create-view.html

票数 9
EN

Stack Overflow用户

发布于 2013-11-28 14:03:28

为了获取视图进行编辑/更新,我们使用了两种方法:

代码语言:javascript
复制
Step 1: 

select your view in phpmyadmin and click Export(make sure click check box of Structure& Add DROP VIEW) & GO.you'll see a CREATE VIEW  query like as:CREATE ALGORITHM=UNDEFINED DEFINER=`dbname`@`localhost` SQL SECURITY DEFINER VIEW `vw_name` AS select ..etc..And then remove 'ALGORITHM.....to...DEFINER' part from this query and update/added required field/make changes to the query.and then execute modified view.`


step 2:

    Run the query: SHOW CREATE VIEW `vw_name`
    Expand the result and choose Full Texts.        
    Copy entire contents of the Create View column.
    Make changes to the query.
    Run the query directly (with out the CREATE VIEW... syntax) to make sure it runs as you expect it to.
票数 3
EN

Stack Overflow用户

发布于 2018-08-22 22:38:30

您还可以使用CREATE OR REPLACE VIEW,以避免删除视图的步骤:

  • show create view viewname.Find definition in 'Create View‘column
  • 使用以下命令添加新列:CREATE OR REPLACE VIEW
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15156308

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档