Created
May 16, 2016 16:03
-
-
Save BDF/f3b2a1483a6c19c4f57d8142dd52e99e to your computer and use it in GitHub Desktop.
H2 vs MYSQL differences.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To minimize the differences: | |
1. On the JDBC connection string: 'MODE=MySQL', full example jdbc:h2:mem:test_one;DB_CLOSE_DELAY=-1;MODE=MySQL;DB_CLOSE_ON_EXIT=FALSE;IGNORECASE=TRUE; | |
2. Interactive SQL: SET MODE MySQL; | |
H2 does not like multiple 'ADD COLUMN' commands for one ALTER TABLE. | |
In mysql the following works | |
ALTER TABLE SOME_TABLE | |
ADD COLUMN USER VARCHAR(64) NOT NULL SET DEFAULT '', | |
ADD COLUMN DESCRIPTION VARCHAR(1024) NOT NULL SET DEFAULT '' AFTER USER, | |
ADD COLUMN CREATED TIMESTAMP DEFAULT SET now() AFTER DESCRIPTION, | |
ADD COLUMN MODIFIED TIMESTAMP DEFAULT SET now() AFTER CREATED; | |
In H2 I had to modify it to the following: | |
ALTER TABLE SOME_TABLE ADD COLUMN USER VARCHAR(64) NOT NULL SET DEFAULT '', | |
ALTER TABLE SOME_TABLE ADD COLUMN DESCRIPTION VARCHAR(1024) NOT NULL SET DEFAULT '' AFTER USER, | |
ALTER TABLE SOME_TABLE ADD COLUMN CREATED TIMESTAMP DEFAULT SET now() AFTER DESCRIPTION, | |
ALTER TABLE SOME_TABLE ADD COLUMN MODIFIED TIMESTAMP DEFAULT SET now() AFTER CREATED; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment