简体   繁体   English

Java PreparedStatement对表的评论

[英]Java PreparedStatement Comment on Table

I'm familiar with using java prepared statements to insert/update on a table. 我熟悉使用java预处理语句在表上插入/更新。 In oracle you can add a comment on a table, how would I use a preparedstatement to do that? 在oracle中你可以在表上添加注释,我如何使用preparedstatement来做到这一点?

This was my initial attempt with no luck; 这是我最初的尝试,没有运气;

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

You can use system Oracle table and set comment there with PreparedStatement , like this: 您可以使用系统Oracle表并在那里使用PreparedStatement设置注释,如下所示:

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

Or try to use simple statement: 或者尝试使用简单的声明:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM