Skip to content

alter_view

The alter_view procedure allows changing a view's query without any down time, which can be useful for migrations. The procedure will create a new view with the new query and will start populating it. Once the new view is ready, it will be swapped with the old view atomically. alter_view is a blocking procedure; It will not end until the switch has taken place.

If a change in a column name occurs, Epsio will drop all columns from that column forward, and recreate necessary columns (In databases supporting transaction DDL statements this is done atomically). Any indexes created above these columns will automatically be dropped, so it is critical to ensure all necessary indexes exist after the alter_view operation.

Syntax

CALL epsio.alter_view(
    <view_name>, 
    <new_query>, 
);
Parameter Information
view_name The existing view name for which to change the query.
new_query The new query for the view.

Examples

Altering a view:

CALL epsio.alter_view('countries_population',
    'SELECT country.name, sum(city.secondary_population) AS total_population
    FROM playground.country
    JOIN playground.city ON country.code = city.country_code
    GROUP BY country.name');