选择 * 返回 CLOB

发布于 2024-07-16 06:57:22 字数 147 浏览 8 评论 0原文

我以前没有使用过oracle,我要修改clob数据,因为它有我的家庭电话号码。 但是当我执行 select * from 表显示 CLOB 时,我看不到数据。 如何查看数据以及如何更新?

我需要查询。

I have not used oracle before and I was to modify the clob data as it has my home phone number. But when I do select * from table shows CLOB and I cannot see the data. How can I see the data and how to I Update?

I need the query.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

人│生佛魔见 2024-07-23 06:57:22

PL/SQL Developer 中,选择 ROWID 以及表列:

SELECT  t.*, t.rowid
FROM    mytable t

这将允许您编辑表的数据。

然后只需检查 CLOB 字段附近的 ... 按钮并对其进行编辑。

您可以从文件加载它或只需在编辑字段中键入。

In PL/SQL Developer, select ROWID along with table columns:

SELECT  t.*, t.rowid
FROM    mytable t

This will allow you to edit the table's data.

Then just check a ... button near the CLOB field and edit it.

You can load it from file or just type into the edit field.

妄断弥空 2024-07-23 06:57:22

您使用什么工具来执行查询? sqlplus 会将 clob 列中的 select 截断为参数 long 的值。 如果您使用 sqlplus,则将 long 设置为足够大的值以容纳 clob,然后执行简单的选择应该返回数据。 Clob 只是文本,因此可以像表中的任何其他列一样进行查询。 如果您使用 sqlplus 并且它不返回任何内容而不是部分返回,那么请确保表中的列已填充。

What tool are you using to perform the query? sqlplus will truncate select from a clob column to the value of the parameter long. If you are using sqlplus then set long to a large enough value to hold the clob and then doing a simple select should return data. Clobs are just text so it can be query as any other column in a table. If you are using sqlplus and it returns nothing instead of partial, then make sure the column in the table is populated.

梦忆晨望 2024-07-23 06:57:22

在代码中?

Java(更新作为 dbo 对象中的字段保存的 CLOB 字段):

String sql = "SELECT clobby_wobby FROM table WHERE uuid = ? FOR UPDATE";
PreparedStatement ps = conn.prepareStatement(sql);
ps.setLong(1, dbo.getUID());
ResultSet rs = ps.executeQuery();
if (rs.next()) {
    oracle.sql.CLOB clob = (oracle.sql.CLOB) ((OracleResultSet) rs).getClob(1);
    failed = writeClob(clob, dbo.getClobbyWobby());
}
rs.close();
ps.close();

其中 writeClob() 是:

protected boolean writeClob(oracle.sql.CLOB clob, String data) throws SQLException {

    if (data == null) { return false; }
    return writeClob(clob, data.toCharArray());
}

protected boolean writeClob(oracle.sql.CLOB clob, char[] data) throws SQLException {

    if (data == null || clob == null) { return false; }
    char[] buffer = new char[clob.getBufferSize()];
    Writer os = clob.getCharacterOutputStream();
    int len = -1;
    CharArrayReader car = new CharArrayReader(data);
    try {
        while ((len = car.read(buffer)) != -1) {
            os.write(buffer, 0, len);
            os.flush();
        }
    } catch (IOException ioe) {
        logger.error("IOException copying clob data into DB", ioe);
        return false;
    } finally {
        try {
            car.close();
            os.close();
        } catch (IOException ioe) {}
    }
    return true;
}

有时我想知道为什么该死的 Oracle 驱动程序本身无法检测到字段是 CLOB 并且只是透明地处理 ps。 setString("非常长的值"); 本身...有人回复说“为什么不使用 Oracle LOB Java 实用程序方法?!” 我从来不知道...

In code?

Java (updating a CLOB field held as a field in an object called dbo):

String sql = "SELECT clobby_wobby FROM table WHERE uuid = ? FOR UPDATE";
PreparedStatement ps = conn.prepareStatement(sql);
ps.setLong(1, dbo.getUID());
ResultSet rs = ps.executeQuery();
if (rs.next()) {
    oracle.sql.CLOB clob = (oracle.sql.CLOB) ((OracleResultSet) rs).getClob(1);
    failed = writeClob(clob, dbo.getClobbyWobby());
}
rs.close();
ps.close();

where writeClob() is:

protected boolean writeClob(oracle.sql.CLOB clob, String data) throws SQLException {

    if (data == null) { return false; }
    return writeClob(clob, data.toCharArray());
}

protected boolean writeClob(oracle.sql.CLOB clob, char[] data) throws SQLException {

    if (data == null || clob == null) { return false; }
    char[] buffer = new char[clob.getBufferSize()];
    Writer os = clob.getCharacterOutputStream();
    int len = -1;
    CharArrayReader car = new CharArrayReader(data);
    try {
        while ((len = car.read(buffer)) != -1) {
            os.write(buffer, 0, len);
            os.flush();
        }
    } catch (IOException ioe) {
        logger.error("IOException copying clob data into DB", ioe);
        return false;
    } finally {
        try {
            car.close();
            os.close();
        } catch (IOException ioe) {}
    }
    return true;
}

and sometimes I wonder why the darned Oracle driver itself can't detect that a field is a CLOB and just transparently cope with ps.setString("very long value"); itself... and this is where someone replies saying "why not use Oracle LOB Java utility methods?!" that I never knew about...

姐不稀罕 2024-07-23 06:57:22

您使用的是旧版本的 sqlplus 吗?

如果您使用的是sql Developer,只需将网格的列加宽即可。

Are you using an old version of sqlplus?

If you are using sql developer, just make the column of the grid wider.

风筝有风,海豚有海 2024-07-23 06:57:22

我正在使用 dbVisualizer,并进行了定期更新并且它有效。 感谢 MichaelN 告知 Clob 只是文本,因此可以像表中的任何其他列一样进行查询。 这帮助我在几分钟内解决了我的问题。

I am using dbVisualizer and I did a regular update and it worked. Thanks MichaelN for informing that Clobs are just text so it can be query as any other column in a table. This helped me fix my issue in few minutes.

予囚 2024-07-23 06:57:22

我针对您的情况提出我的方法:这是 pl/sql 中的示例。 您可以创建一个从 clob 读取的过程。

  Declare 
  Variableclob Clob;
  Temp_Save Varchar2(32767);
  index_pass number;
  Begin

  For I In (select id_reporte from reporte where id_reporte between 201 and 218)
  Loop
  Index_Pass:=To_Number(I.Id_Reporte);
  Select Consulta Into Temp_Save From Reporte Where Id_Reporte=Index_Pass;
  Variableclob:=To_Clob(Temp_Save);

  Dbms_Output.Put_Line(Variableclob);

  End Loop ;
  End;

  Remember to use:
  set serveroutput on;
  begin DBMS_OUTPUT.ENABLE(9999999999999); end;

I present my approach for you situation: This is an example in pl/sql. You can create a procedure for read from clob.

  Declare 
  Variableclob Clob;
  Temp_Save Varchar2(32767);
  index_pass number;
  Begin

  For I In (select id_reporte from reporte where id_reporte between 201 and 218)
  Loop
  Index_Pass:=To_Number(I.Id_Reporte);
  Select Consulta Into Temp_Save From Reporte Where Id_Reporte=Index_Pass;
  Variableclob:=To_Clob(Temp_Save);

  Dbms_Output.Put_Line(Variableclob);

  End Loop ;
  End;

  Remember to use:
  set serveroutput on;
  begin DBMS_OUTPUT.ENABLE(9999999999999); end;
稀香 2024-07-23 06:57:22

在 SQL Developer 中,“打开”表。 选择“数据”选项卡(这将检索所有数据)。 然后在过滤器栏(顶部)中,提供获取要更新的单行的条件。 更新所需的列,然后提交更改。

In SQL developer, "Open" table. Select the "Data" tab (this will retrieve all data). Then in the Filter bar (top side), provide your criteria to get to the single row that you want to update. Update the required column(s) and then Commit the changes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文