next-jdbc:执行多个语句? [英] next-jdbc: execute multiple statements?
问题描述
我正在使用新的seancorfield/next.jdbc
库在clojure中编写一个简单的数据库迁移代码.
I'm writing a simple database migration code in clojure using the new seancorfield/next.jdbc
library.
如何一次执行多个SQL语句?用例是我有一个SQL文件,其中包含用于从一个版本迁移到下一个版本的查询代码. next.jdbc/execute!
仅按设计执行一条语句.
How do I execute several SQL statements at once? The usecase is that I have a SQL file containing query code for migrating from one version to the next. next.jdbc/execute!
only executes one statement as designed.
推荐答案
在单个JDBC操作中是否可以执行多个语句取决于数据库.某些数据库允许在单个操作中使用分号分隔的多个语句.如果JDBC驱动程序支持它,则next.jdbc
也将支持它.
Whether you can execute multiple statements in a single JDBC operation is database-dependent. Some databases allow multiple statements in a single operation, separated by a semicolon. If the JDBC driver supports it, next.jdbc
will also support it.
如果您的JDBC驱动程序不支持它,则需要进行多个execute!
调用.有些数据库允许您将多个DDL操作包装在一个事务中(其中一些忽略该事务,并且无论如何都要分别提交每个DDL操作),有些数据库明确禁止围绕DDL操作的事务.
If your JDBC driver does not support it, you'll need to make multiple execute!
calls. Some databases allow you to wrap multiple DDL operations in a transaction (some of them ignore the transaction and commit each DDL operation separately anyway), some databases explicitly disallow a transaction around DDL operations.
这篇关于next-jdbc:执行多个语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!