My application uses MySQL database and it has table utils.'{UserUtils}'. I need to write a test that would use the same queries, but with the H2 database for tests. But I can't create such a table in H2, I have error:
Syntax error in SQL statement
"create table utils.`{UserUtils}`[*]" [42000-196]
Is it possible to somehow tell H2 to create such a table or are the names strictly limited?
In MySQL, you need to enclose identifiers with special characters using back quotes (`). However, in H2 the correct way of using identifiers with special characters is to enclose them in double quotes ("). I just tried in H2 v1.4 without any trouble:
create table "{UserUtils}" (
id int
);
insert into "{UserUtils}" (id) values (123);
insert into "{UserUtils}" (id) values (456);
select * from "{UserUtils}";
Returns:
ID
-------------
123
456
Maybe you are using an older/newer version of H2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With