Question

I want to change a view which already exists. Isn't there something like \changeView or \alterView in Liquibase?

I already created a view with createView. I tried to use google and search for alterview or changeview, but without any proper results.

Was it helpful?

Solution 2

The simplest approach is to drop the old view and create a new one. Re-creating a view does not affect your data.

OTHER TIPS

There is a replaceIfExists attribute on createView that will replace an existing view.

http://www.liquibase.org/documentation/changes/create_view.html

I know this question is 6 years ago, but can be util for so today.

Liquibase has an option for <createView> which is replaceIfExists="yourBooleanOpt". So you can use:

<createView
  viewName="yourViewName"
  replaceIfExists="true">
     yourSqlViewSintax
</createView>

Because of some reasons, I could not change or replace my view using either <sql> or <createView> tags. So, I created sql file with my view definition, and in my changeset I have included this sql file using <sqlFile> tag. This tag has attribute dbms and it is required, so, do not forget to write correct one. In this way I have changed/updated my existing view. Hope this helps to someone like me.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top