Search code examples
mysqlviewphpmyadmin

How to update a view in phpMyAdmin?


How can I update (or edit) a View in MySQL database using phpMyAdmin.

I got a view that's made of columns from two tables - I added a new column to one of these, but the view doesn't have it. I can't find the MySQL query I used to get this view (it's quite obscure one) - so how can I edit the MySQL query that created this view to add a new column into it?


Solution

  • How about using (Your view is called viewname)

    1. SHOW CREATE VIEW viewname to get the SQL for the view as it is
    2. DROP VIEW viewname to remove the view
    3. Modify the SQL from the first step to add the new column to that SQL
    4. Run the modified SQL

    That would create the view with the additional column(s)

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