Chris311
Chris311

Reputation: 3992

How to change a view in Liquibase

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.

Upvotes: 1

Views: 14614

Answers (4)

Khasan 24-7
Khasan 24-7

Reputation: 467

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.

Upvotes: 0

Omar Kafer
Omar Kafer

Reputation: 101

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>

Upvotes: 5

shelley
shelley

Reputation: 7324

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

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

Upvotes: 13

Mark O&#39;Connor
Mark O&#39;Connor

Reputation: 78001

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

Upvotes: 5

Related Questions