11

I'm new in using in-memmory database.

I tried to use H2 database for developing project with spring boot, spring data JPA, but i got a problem when initialize application.

Caused by: org.h2.jdbc.JdbcSQLException: Unknown data type: "FK_PERSON__PERSONTYPE_IDX"; SQL statement:

Because this script was exported from MySQL. So i thinked there are some wrong syntax which H2 does not understand

For example, this is a part of script:

CREATE TABLE `person` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `firstname` varchar(255) NOT NULL,
  `lastname` varchar(255) DEFAULT NULL,
  `type` int(11) NOT NULL,
  `address` text,
  PRIMARY KEY (`id`),
  KEY `fk_person__persontype_idx` (`type`),
  CONSTRAINT `fk_person__persontype` FOREIGN KEY (`type`) REFERENCES `persontype` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='  ';

And i tried some solutions from these:

Convert MySQL script to H2

http://matthewcasperson.blogspot.de/2013/07/exporting-from-mysql-to-h2.html

Replace symbols with double quotes, single quotes,... even not use quote at all but not working. Please show me why? Thank you.

Community
  • 1
  • 1
vietsanto
  • 111
  • 1
  • 1
  • 6
  • Possible duplicate of [SQL commands not compliable by H2](http://stackoverflow.com/questions/35676516/sql-commands-not-compliable-by-h2) – win_wave Apr 20 '16 at 10:36
  • Thanks, let me check it. – vietsanto Apr 24 '16 at 05:55
  • Thanks win_wave for recommend, but not success. There are still many errors when i migrate from mysql script to H2 script. It's better to use mysql DB – vietsanto May 02 '16 at 15:07

1 Answers1

1

I had a similar issue.

Removing the "KEY" line, which in your example corrosponds to:

KEY `fk_person__persontype_idx` (`type`),

worked for me.

Søren
  • 111
  • 2
  • 11