Java PreparedStatement对表的评论

时间:2016-08-19 20:38:09

标签: java sql oracle prepared-statement

我熟悉使用java预处理语句在表上插入/更新。在oracle中你可以在表上添加注释,我如何使用预备语句来做到这一点?

这是我最初的尝试,没有运气;

PreparedStatement stmt = con.prepareStatement("comment on table my_table is q'[?]'");
stmt.setString(1, description);
stmt.executeUpdate();

1 个答案:

答案 0 :(得分:0)

您可以使用系统Oracle表并在PreparedStatement处设置注释,如下所示:

PreparedStatement stmt = con.prepareStatement(
    "UPDATE user_tab_comments SET comments = ? WHERE table_name = 'my_table'");

或者尝试使用简单的声明:

String commentOnTableSQL = String.format("COMMENT ON TABLE my_table is '%s'", comment);
Statement statement = dbConnection.createStatement();
statement.execute(commentOnTableSQL);