我熟悉使用 java 准备好的语句在表上插入/更新。在 Oracle 中,您可以在表上添加注释,我将如何使用准备好的语句来做到这一点?
这是我最初的尝试,但没有成功;
PreparedStatement stmt = con.prepareStatement("comment on table my_table is q'[?]'");
stmt.setString(1, description);
stmt.executeUpdate();
最佳答案
您可以使用系统 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);
关于JavaPreparedStatement 表的注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39047322/