0

I have a SQL problem with a h2 database. I want to add a column but always get an error although I strictly stick to the syntax.

Example:

create table t1 (c1 bool,c3 bool);
alter table t1 add column c2 bool after c1;

Creating the table is no problem. But when it comes to the second line a get the following error:

Syntax error in SQL statement "ALTER TABLE T1 ADD COLUMN C2 BOOL AFTER[*] C1 "; SQL statement:
alter table t1 add column c2 bool after c1 [42000-168] 42000/42000 (Help)

What am I doing wrong?

Edit: The same error message is displayed when I omit "column":

alter table t1 add c2 bool after c1;
principal-ideal-domain
  • 3,998
  • 8
  • 36
  • 73

3 Answers3

1

Please remove the column

create table t1 (c1 bool,c3 bool);
alter table t1 add c2 bool after c1;
0

Per the posted H2 documentation link the syntax for ALTER is

ALTER TABLE TEST ADD CREATEDATE TIMESTAMP

So from your posted ALTER query as below, only difference it inclusion of column

alter table t1 add column c2 bool after c1;

EDIT:

Per H2 Spec AFTER and BEFORE should work but if it doesn't work then spec is wrong. In that case, either try removing AFTER c1 or try using BEFORE c3 instead of AFTER c1.

Rahul
  • 76,197
  • 13
  • 71
  • 125
0

Due to Rahul I've found a way to solve a problem although the solution doesn't tell me why my first approach didn't succeed.

Instead of using "after" using "before" doesn't invoke error messages:

alter table t1 add column c2 bool before c3;
principal-ideal-domain
  • 3,998
  • 8
  • 36
  • 73