# Liquibase insert failing with Table not found in H2

**URL:** <https://forum.liquibase.org/t/liquibase-insert-failing-with-table-not-found-in-h2/5828>\
**Category:** Liquibase Development\
**Created:** [August 24, 2021, 9:39am UTC](https://forum.liquibase.org/t/liquibase-insert-failing-with-table-not-found-in-h2/5828 "2021-08-24T09:39:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![DEEPAK](https://avatars.discourse-cdn.com/v4/letter/d/7bcc69/32.png) [@DEEPAK](https://forum.liquibase.org/u/DEEPAK)\
**Post date:** [August 24, 2021, 9:39am UTC](https://forum.liquibase.org/t/liquibase-insert-failing-with-table-not-found-in-h2/5828/1 "2021-08-24T09:39:34Z")

</div>

Hello,  
I am using liquibase 4.3.3 to insert data to H2 DB using yaml changeset. But, when I try to start the server I get table not found while inserting even though the table exists. But, if I use the generated insert statement and disable liquibase and use spring.sql.init.data-locations to specify the data file having insert SQL statement, this works. Can you please help me out with this weird problem?

Regards,  
Deepak

---

<div class="post-metadata">

**Author:** ![rakhi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.liquibase.org/rakhi/32/288_2.png) [@rakhi](https://forum.liquibase.org/u/rakhi)\
**Post date:** [August 25, 2021, 10:17am UTC](https://forum.liquibase.org/t/liquibase-insert-failing-with-table-not-found-in-h2/5828/2 "2021-08-25T10:17:05Z")

</div>

Hi @DEEPAK

Could you please help us with more details?

1. Does this only happens when you use YAML changeset? and works with XML or SQL changeset?
2. Could you paste the error log here? it will get more clarity on the exact issue.
3. Please share the YAML changeset file with us.

Also, please help me understand what do you mean by this:

> [@DEEPAK](#):
>
> if I use the generated insert statement and disable liquibase and use spring.sql.init.data-locations to specify the data file having insert SQL statement, this works.

What is generated insert statement here?

Thanks,  
Rakhi Agrawal

---

<div class="post-metadata">

**Author:** ![DEEPAK](https://avatars.discourse-cdn.com/v4/letter/d/7bcc69/32.png) [@DEEPAK](https://forum.liquibase.org/u/DEEPAK)\
**Post date:** [August 25, 2021, 11:17am UTC](https://forum.liquibase.org/t/liquibase-insert-failing-with-table-not-found-in-h2/5828/3 "2021-08-25T11:17:43Z")

</div>

Hello @rakhi,

Please find below the answers to your question

1. Does this only happens when you use YAML changeset? and works with XML or SQL changeset?  
This happens irrespective of what kind of changeset it is. I tried with SQL, yaml and XML and all had the same issue.
2. Could you paste the error log here? it will get more clarity on the exact issue.  
Please find below

```auto
2021-08-25 13:08:27.265 INFO 62336 --- [main] liquibase.lockservice : Successfully acquired change log lock
2021-08-25 13:08:27.506 INFO 62336 --- [main] liquibase.changelog : Creating database history table with name: PUBLIC.COM_SAP_GRC_RISK_ASSESSMENT_DATABASECHANGELOG
2021-08-25 13:08:27.509 INFO 62336 --- [main] liquibase.changelog : Reading from PUBLIC.COM_SAP_GRC_RISK_ASSESSMENT_DATABASECHANGELOG
2021-08-25 13:08:27.545 INFO 62336 --- [main] liquibase.changelog : Change set liquibase/data/test-insert.xml::Analysis-1::Test failed, but failOnError was false. Error: Table "COM_TEST_LIQUIBASE_ANALYSIS" not found; SQL statement:
INSERT INTO PUBLIC.COM_TEST_LIQUIBASE_ANALYSIS (ID, name, description, sortOrder, parent_ID, owner, removed) VALUES ('9926ee2b-a22d-4a49-9a46-073e20dcdc9d', 'Test Liquibase', 'Test', 0, '9926ee2b-a22d-4a49-9a46-073e20dcdc9d', 'Test', FALSE) [42102-200] [Failed SQL: (42102) INSERT INTO PUBLIC.COM_TEST_LIQUIBASE_ANALYSIS (ID, name, description, sortOrder, parent_ID, owner, removed) VALUES ('9926ee2b-a22d-4a49-9a46-073e20dcdc9d', 'Test Liquibase', 'Test', 0, '9926ee2b-a22d-4a49-9a46-073e20dcdc9d', 'Test', FALSE)]
2021-08-25 13:08:27.547 INFO 62336 --- [main] liquibase.lockservice : Successfully released change log lock

```

1. Please share the YAML changeset file with us.  
My changelog.yaml  

The generated statement is the insert statement generated by liquibase as you can also see in the logs which I have posted. So, If i take this and directly go to h2-console and try to run then it works.

---

<div class="post-metadata">

**Author:** ![DEEPAK](https://avatars.discourse-cdn.com/v4/letter/d/7bcc69/32.png) [@DEEPAK](https://forum.liquibase.org/u/DEEPAK)\
**Post date:** [August 31, 2021, 10:04am UTC](https://forum.liquibase.org/t/liquibase-insert-failing-with-table-not-found-in-h2/5828/4 "2021-08-31T10:04:41Z")

</div>

Hello,  
Any update on this?

---

<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 31, 2021, 12:19pm UTC](https://forum.liquibase.org/t/liquibase-insert-failing-with-table-not-found-in-h2/5828/5 "2021-08-31T12:19:54Z")

</div>

I’ll preface by saying that I’m not familiar with H2, but here are a couple of observations…

I see “PUBLIC” schema prefix on the table name in the Liquibase log. Are you running that exact statement in the h2-console.

Is the userid that you are using to run the insert in the h2-console the same as the userid that Liquibase runs as?

---

<div class="post-metadata">

**Author:** ![DEEPAK](https://avatars.discourse-cdn.com/v4/letter/d/7bcc69/32.png) [@DEEPAK](https://forum.liquibase.org/u/DEEPAK)\
**Post date:** [August 31, 2021, 1:52pm UTC](https://forum.liquibase.org/t/liquibase-insert-failing-with-table-not-found-in-h2/5828/6 "2021-08-31T13:52:14Z")

</div>

HI @daryldoak  
I tried the exact insert statement with PUBLIC in h2-console and it worked. The username is coming from the spring boot data source and I too use the same to login to h2-console and I am pretty much sure even liquibase uses the same username.
