我有一个程序,它接受一组sql/plsql文件,主要包含DDL,并在打开到数据库的连接后执行其内容。
try (Connection connection = DriverManager.getConnection(jdbcUrl, username, passwd)) {
if (connection != null) {
for (String sqlFile : sqlFiles) {
Statement statement = connection.createStatement();
List<String> sqls = readFile(sqlFile);
for (String sql : sqls) {
statement.executeUpdate(sql);
}
}
}
} catch (SQLException ex) {
}
// readFile(String fileName) returns the list of queries separated by "/" for .plsql and ";" for .sql files我在stackoverflow中看到了很多关于如何删除单行和多行注释的问题。但是,当我测试包含注释(多行和单行)的文件时,我没有遇到任何问题,脚本也可以正常执行。
那么,在执行Statememt.executeUpdate()方法之前,我可以在sql string中保留注释吗?即使现在它在测试数据上运行良好,我以后还会面临问题吗?
发布于 2019-12-05 17:40:22
您不必从脚本中删除注释,只需确保正确注释了所有应该包含的内容,以避免失败。
如果您需要更多信息,这里有一些关于注释的很好的Oracle文档:
https://docs.oracle.com/cd/B12037_01/server.101/b10759/sql_elements006.htm#BEGIN
https://stackoverflow.com/questions/59175265
复制相似问题