【发布时间】:2016-01-12 05:12:21
【问题描述】:
基本上我想从 Postgres 中的 SQL 文件执行 SQL 文件。
mysql 的类似问题:is it possible to call a sql script from a stored procedure in another sql script?
为什么?
因为我在一个项目中有 2 个数据文件,并且我希望有一行可以注释/取消注释来加载第二个文件。
说明: 我想从 A.SQL 调用 B.SQL
澄清2: 这适用于使用休眠从初始 SQL 文件 (A.SQL) 创建数据库的 Spring 项目。
进一步思考,我似乎必须从 java/string/hibernate 处理这个问题。
下面是配置文件:
spring.datasource.url=jdbc:postgresql://localhost:5432/dbname
spring.datasource.username=postgres
spring.datasource.password=root
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.data=classpath:db/migration/postgres/data.sql
spring.jpa.hibernate.ddl-auto=create
【问题讨论】:
-
你想如何执行sql文件?用 psql 吗?
-
@Tommaso Di Bucchianico 我想从另一个文件中调用一个 sql 文件。
标签: spring hibernate postgresql jpa