First of all I would like to say am new to h2 database. I need to execute a sql script file in h2 database. I have a script file test.sql and I want to execute this in h2 database. Is it possible?
相关问题
- H2 database: clustered indexes support
- JPA Entity Manager - How to run SQL script file?
- How to run 2 SQL “SELECT”s atomically? Or any othe
- Can you create multiple catalogs in H2?
- H2 console access for databases other than h2
相关文章
- 小型数据库(SQLite,Derby,H2)可以存储多少数据?
- Setup password for H2
- Any ideas for persisting H2 Database In-Memory mod
- How to write sql query whose conditions are option
- H2 in-mem-DB with hibernate set to create giving m
- Dropping unique constraint for column in H2
- H2 not creating/updating table in my Spring Boot a
- Embedding an H2 Database within the WEB-INF Direct
You can use the RUNSCRIPT SQL statement:
or you can use the RunScript standalone / command line tool:
You can also use the RunScript tool within an application:
If you are using spring-boot and spring-test with H2 it will automatically look for
schema.sql
anddata.sql
in your class path and attempt to run these. So if you put them insrc/test/resources
they should be picked up and run automaticallyIn addition you can specify the data files you want to run with properties. For example adding a property to your
application.properties
likewill configure spring to run those three sql files instead of running
data.sql
For me the system responded with:
The solution was:
See: http://www.h2database.com/html/tutorial.html#using_server
On OSX (this shouldn't really matter) with v. 1.4.192 with the following commands, no matter what I did I could not see any results:
where select.sql had simply:
I had to add the
-showResults
before output began appearing. Here is the complete command:If you do not have the needed jar, download from here (Click on the
jar
links next to each version). Some direct links to the jars are as follows:1.4.193 (Updated 31-Oct-2016)
1.4.192 (Updated 26-May-2016)
1.4.191 (Updated 21-Jan-2016)
1.4.190 (Updated 11-Oct-2016)