Has CHECK become a keyword in H2 v1.4?

162 views
Skip to first unread message

Henrik Wetterström

unread,
Jul 4, 2017, 8:48:27 AM7/4/17
to H2 Database
Hi,

the SQL statement below works in version 1.3.175 but fails in 1.4.195.

CREATE TABLE CHECK(ID INTEGER NOT NULL, NAME VARCHAR(32) NOT NULL);

The error in 1.4.195 is:

Syntax error in SQL statement "CREATE TABLE CHECK[*]( ID INTEGER NOT NULL, NAME VARCHAR(32) NOT NULL)"; expected "identifier"; SQL statement:
CREATE TABLE CHECK( ID INTEGER NOT NULL, NAME VARCHAR(32) NOT NULL) [42001-196] 42001/42001 (Help)

It works in both versions of H2 if I create a table with a different name than CHECK. The H2 documentation doesn't include CHECK as one of the keywords.
In my case, I work with a legacy system with a large amount of data and several surrounding systems, so I can't easily pick a different name so I am kind of stuck with one of the tables having this unfortunate name.
Before attempting to start a such journey would I like to get some input on this matter.

Regards,
Henrik

Noel Grandin

unread,
Jul 4, 2017, 8:56:18 AM7/4/17
to h2-da...@googlegroups.com, Henrik Wetterström
Hmmm, that is a pity.

CHECK has always been a keyword, e.g.
http://h2database.com/html/grammar.html#alter_table_add_constraint

but we only recently became more pedantic about it to avoid ambiguity in the CREATE TABLE syntax.

Your best bet is to escape all such usages using quotes.

Henrik Wetterström

unread,
Jul 4, 2017, 9:45:25 AM7/4/17
to H2 Database, henrik.we...@gmail.com
Thanks a lot for your quick answer!
I will go for escaping using quotes. It seems to solve the issue I got.

Regards,
Henrik
Reply all
Reply to author
Forward
0 new messages