# CreateView and schema

**URL:** <https://forum.liquibase.org/t/createview-and-schema/3083>\
**Category:** General Discussion\
**Created:** [August 14, 2014, 10:06pm UTC](https://forum.liquibase.org/t/createview-and-schema/3083 "2014-08-14T22:06:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZbynekVavros](https://avatars.discourse-cdn.com/v4/letter/z/9dc877/32.png) [@ZbynekVavros](https://forum.liquibase.org/u/ZbynekVavros)\
**Post date:** [August 14, 2014, 10:06pm UTC](https://forum.liquibase.org/t/createview-and-schema/3083/1 "2014-08-14T22:06:00Z")

</div>

Hey guys (and possible girls 🙂

I have found an interesting “issue” when using LiquiBase to create database views.  
My app is running on WebSphere and using JNDI data source that has no scheme defined (as it is used by more then one application and each application specifies schema in its own configuration).

In Hibernate I can specify schema using :

1. ${jdbc.schema}

 In LiquiBase I can do the same using Spring's integration : 
1.  
2. &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
3. &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
4. &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
5. &nbsp;&nbsp;&nbsp; 

 Now imagine that I have a view to be created : 
1.  
2. &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; replaceIfExists is not allowed on db2
3. &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
4. &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; SELECT ROWNUMBER() OVER() as ID, MAD\_SERVER\_ID as MAD\_SERVER\_ID, SUBSTR( xmlserialize
5. (xmltext (concat (’,’, MAD\_SERVER\_PROPERTY.NAME))) AS VARCHAR(255)), 2)

6. &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; as PROPERTIES FROM mad\_server INNER JOIN MAD\_SERVER\_TO\_PROPERTY ON MAD\_SERVER\_TO\_PROPERTY.MAD\_SERVER\_ID

7. mad\_server.ID INNER JOIN MAD\_SERVER\_PROPERTY ON MAD\_SERVER\_TO\_PROPERTY.PROPERTY\_ID

8. &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; = MAD\_SERVER\_PROPERTY.ID GROUP BY MAD\_SERVER\_ID
9. &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
10. &nbsp;&nbsp;&nbsp; 

 When this changeSet gets executed it will look for table ‘mad\_server’ (please don’t laugh) in default schema (which is same as DB user) rather than in schema I provided via Spring.And since the table is in schema I provided this SQL fails - obviously.  
I could put SCHEMA.mad\_server into the SQL but that would loose the portability.

Any idea how this could be done? Or is it database (or DB2) related “issue”/feature.

All this happens on DB2 9.7.

Thanks !

PS : If I use local data source with schema specified it work fine !

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [August 14, 2014, 10:06pm UTC](https://forum.liquibase.org/t/createview-and-schema/3083/2 "2014-08-14T22:06:00Z")

</div>

If you are wanting to inject variables into the body of the view, the best approach is probably to use changelog parameters. [http://www.liquibase.org/documentation/changelog\_parameters.html&nbsp;](http://www.liquibase.org/documentation/changelog_parameters.html%C2%A0)

That will allow you to “hard code” a schema-identified table in the changelog file but change what that value is at runtime.

Nathan
