如何使用phpMyAdmin更新(或编辑) MySQL数据库中的视图。
我得到了一个由两个表中的列组成的视图-我在其中一个表中添加了一个新列,但视图中没有它。我找不到用于获取该视图的MySQL查询(它相当模糊)-那么如何编辑创建该视图的MySQL查询以向其中添加新列呢?
发布于 2013-03-01 19:18:34
如何使用(您的视图称为viewname)
SHOW CREATE VIEW viewname获取视图的SQL原样为DROP VIEW viewname删除视图这将创建包含附加列的视图
http://dev.mysql.com/doc/refman/5.0/en/show-create-view.html
发布于 2013-11-28 14:03:28
为了获取视图进行编辑/更新,我们使用了两种方法:
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.发布于 2018-08-22 22:38:30
您还可以使用CREATE OR REPLACE VIEW,以避免删除视图的步骤:
show create view viewname.Find definition in 'Create View‘columnCREATE OR REPLACE VIEWhttps://stackoverflow.com/questions/15156308
复制相似问题