# Managing common SQL code in postgres database via liquibase

**URL:** <https://forum.liquibase.org/t/managing-common-sql-code-in-postgres-database-via-liquibase/7224>\
**Category:** General Discussion\
**Created:** [August 21, 2022, 3:14pm UTC](https://forum.liquibase.org/t/managing-common-sql-code-in-postgres-database-via-liquibase/7224 "2022-08-21T15:14:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tuk](https://avatars.discourse-cdn.com/v4/letter/t/b5ac83/32.png) [@tuk](https://forum.liquibase.org/u/tuk)\
**Post date:** [August 21, 2022, 3:14pm UTC](https://forum.liquibase.org/t/managing-common-sql-code-in-postgres-database-via-liquibase/7224/1 "2022-08-21T15:14:47Z")

</div>

We are using [SQL formatted changelogs](https://docs.liquibase.com/concepts/changelogs/sql-format.html). We have a sql file, `create_db.sql` for each postgres database managed via liquibase. We have few common tables for each database which is placed in a `common.sql` file.

It looks like [include](https://docs.liquibase.com/concepts/changelogs/attributes/include.html) element can serve my purpose. But it does not work with SQL formatted changelogs.

One approach I can think of handling this case is to not have common.sql altogether and place all the common code in each `create_db.sql` as I could not find any good way of importing `common.sql` in each create\_db.sql to be managed via liquibase using sql formatted changelogs. But this will cause a lot of code duplication.

Can someone suggest some other better way of managing the `common.sql` file also via liquibase for each postgres database?

---

<div class="post-metadata">

**Author:** ![daryldoak](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.liquibase.org/daryldoak/32/764_2.png) [@daryldoak](https://forum.liquibase.org/u/daryldoak)\
**Post date:** [August 22, 2022, 1:16pm UTC](https://forum.liquibase.org/t/managing-common-sql-code-in-postgres-database-via-liquibase/7224/3 "2022-08-22T13:16:24Z")

</div>

Formatted SQL changelogs do work with the include tag, there is an example on the documentation page, and this is stated on the page:

“Your reference changelog can be SQL, XML, YAML, or JSON file types.”

---

<div class="post-metadata">

**Author:** ![tuk](https://avatars.discourse-cdn.com/v4/letter/t/b5ac83/32.png) [@tuk](https://forum.liquibase.org/u/tuk)\
**Post date:** [August 22, 2022, 2:20pm UTC](https://forum.liquibase.org/t/managing-common-sql-code-in-postgres-database-via-liquibase/7224/4 "2022-08-22T14:20:41Z")

</div>

Ok right. `<include>` tag cannot be used in an SQL formatted root changelog.
