1
  • How i could define some schema and data to be inserted into db for sql database in spring boot
  • Also could i do this for embedded databases

For example i am using two databases and i want to populate some data or define some schema and apply to different databases before application starts.

1 Answer 1

2

A file named import.sql in the root of the classpath is executed on startup if Hibernate creates the schema from scratch (that is, if the ddl-auto property is set to create or create-drop). This can be useful for demos and for testing if you are careful but is probably not something you want to be on the classpath in production. It is a Hibernate feature (and has nothing to do with Spring).

You can take a look in spring docs

Sign up to request clarification or add additional context in comments.

1 Comment

just to enhance the answer - he can use schema.sql and data.sql files to manualy define the schema and to separate concerns, or to create build or platform specific scripts, as is already stated in the linked docs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.