JavaPreparedStatement 表的注释

标签 java sql oracle prepared-statement

我熟悉使用 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/

相关文章:

java - 获取图像中特定区域的主色 : Color Query for Web Page Elements

sql - 使用 HiveQL 分解结构数组

oracle - 从过程中调用带有表参数的函数时出现编译错误

sql-server - 全局临时表 - SQL Server 与 Oracle

php - Codeigniter 和 oracle 未定义常量 : OCI_COMMIT_ON_SUCCESS

java - 启动 Windows 10 Paint3D 以打开特定图像文件

java - 在 Spring 中为每个 HTTP 请求清除/初始化列表(集合)

java - LibGDX (OpenGL) 中 ShapeRender 的纵横比

php - 使用计数而不是 mysql_num_rows?

sql - SQL 查询的 NULL NOT IN (Empty_Relation) 在不同的引擎上显示不同的行为