简体   繁体   中英

How to get ddl auto generated script in Spring boot JPA/Hibernate?

Is there a way to quickly get initial SQL script for the database that is being generated by hibernating through ddl-auto property?

I would like to get an initial SQL script for the flyway as a quick start.

  1. use property spring.jpa.show-sql = true and it will print all script on console in format.

控制台上的休眠脚本

  1. use ddl-auto as you did and take backup of schema for your respective DB and use that as initial script

example - mysql , postgres

You can see the DDL script generated by Hibernate in a Spring boot application by setting the logging level of Hibernate to debug mode in the application.properties file of your project.

logging.level.org.hibernate.SQL=DEBUG

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM