Diego S. Vega
Diego S. Vega

Reputation: 1

Create two tables in same schema.sql H2

I'm using Spring boot, and I have to initiate two tables for testing. I'm using the schema.sql inside the resource folder. But when I'm trying to create two tables in the same script and run the app, it can't load the application context.

Here is my schema.sql which I have placed at resource folder:

CREATE TABLE JobStatus_FO
(
   id int(11) NOT NULL AUTO_INCREMENT,
   businessDate timestamp NOT NULL,
   label varchar(50),
);
CREATE TABLE JobStatusDetails_FO
{
  id int(11) NOT NULL,
  name varchar(50),
};

Upvotes: 0

Views: 2176

Answers (1)

Suresh
Suresh

Reputation: 489

Please find the correct scripts as

    CREATE TABLE JobStatus_FO
(
   id INT(11) NOT NULL AUTO_INCREMENT,
   businessDate TIMESTAMP NOT NULL,
   label VARCHAR(50),
   KEY id(id)
);
CREATE TABLE JobStatusDetails_FO
(
  id INT(11) NOT NULL,
  NAME VARCHAR(50)
);

Your syntax is not correct of create table . 1) In your scripts you have used extra comma "," before closing parentheses 2) Auto increment column should be used as a key in table 3) Curly braces "{" is not used within create table.

Hope this will work in to your project.

Upvotes: 1

Related Questions