HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

H2 ALTER TABLE ADD COLUMN BEFORE/AFTER

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
aftercolumnbeforealtertableadd

Problem

According to H2 syntax documentation available here I should be able to execute a query like:

ALTER TABLE EMPLOYEE ADD COLUMN SECOND_NAME VARCHAR (124) AFTER FIRST_NAME;


However apparently only this query works:

ALTER TABLE EMPLOYEE ADD COLUMN SECOND_NAME VARCHAR (124);


Is it a mistake in the documentation or am I missing something?
The BEFORE and AFTER parameters would be useful to me.

Solution

It works for me. The H2 change log says it was added in version 1.3.171. Here is the original bug

alter table credentials add column domain VARCHAR(255) after credentialType;


What didn't work for me was having multiple adds inside one alter.

Code Snippets

alter table credentials add column domain VARCHAR(255) after credentialType;

Context

StackExchange Database Administrators Q#44348, answer score: 2

Revisions (0)

No revisions yet.