'How do i update mysql views when a column is added/deleted from the table?

I created a table and then some views for the table. Now i altered the table to add another column in it.But the views are not updated.It doesn't have the column that is added in the table.Is there any way to modify view structure automatically?



Solution 1:[1]

You can have one text/sql file with the definition of all your views and run it everytime you update your tables. So, you don't need to update every view.

Something like that:

DROP VIEW IF EXISTS view1;
CREATE VIEW view1 AS
    SELECT * FROM table1;

DROP VIEW IF EXISTS view2;
CREATE VIEW view2 AS
    SELECT * FROM table2;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Juan Antonio Tubío