3

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.

  • 1
    The order of the columns in a relational table is irrelevant. Just change them in your SELECT statements. – a_horse_with_no_name Jun 12 '13 at 10:20
  • I know it is irrelevant in practice but in the documentation they have put this possibility for a reason. In my case it is that we often print the schema to paper and want some order for readability reasons. – dendini Jun 12 '13 at 11:17
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.