Oracle LOB字段操作的一点教训
今天有个功能需要对CLOB字段进行操作,期间遇到几个问题,老天眷顾,都算是解决了,记一下,免得日后重蹈覆辙。
错误一:
ORA-22920: 未锁定含有 LOB 值的行
出现这个问题的原因,是由于select出LOB字段时未加 for update,ORACLE官方文档对该错误的说明:
引用文字代码
ORA-22920 row containing the LOB value is not locked
Cause: The row containing the LOB value must be locked before updating the LOB value.
Action: Lock the row containing the LOB value before updating the LOB value.
ORA-22920 row containing the LOB value is not locked
Cause: The row containing the LOB value must be locked before updating the LOB value.
Action: Lock the row containing the LOB value before updating the LOB value.
于是加上for update再测,发现错误提示变了,变成下面的:
错误二:
ORA-01002: 读取违反顺序
出现这个问题的原因是Connection 的 autoCommit属性值为true,改成
Sql代码 conn.setAutoCommit(false);
......
LOB操作
.....
conn.commit();
conn.setAutoCommit(true);
conn.setAutoCommit(false);
......
LOB操作
.....
conn.commit();
conn.setAutoCommit(true);
就可以了。
另外,注意第一步的select时,不要select出非LOB的字段,并且,如果一张表有多个LOB字段,操作顺序也最好按照表里的字段顺序来操作,否则也可能出错。
相关文档:
oracle表空间操作详解
1
2
3作者: 来源: 更新日期:2006-01-04
5
6
7建立表空间
8
9CREATE TABLESPACE data01
10DATAFILE '/ora ......
首先计算机上必须安装oracle,并配置好服务名
安装oracle的过程中一般会要求建立一个数据库,也可以之后再创建
这个后面有一个 数据库配置助理 (创建修改数据库的,一般密码创建要求字母开头,大于7位啥的)和一个net配置助理(添加或者修改一个数据库服务名),一般用plsql developer远程操作oracle数据库 ......
我们先来看一下他们的定义:
A schema is a collection of database objects (used by a user.).
Schema objects are the logical structures that directly refer to the database’s data.
A user is a name defined in the database that can connect to and access objects.
Schemas and users help database ......
參考:http://blog.csdn.net/rainnyzhong/archive/2009/01/09/3740660.aspx
作者:Rainny
日期:2009-1-8
创建测试表:
create table test(c_id varchar2(20));
插入测试数据:
insert into test values ('1234');
insert into test values ('45678');
insert into test values ('-12 ......
一、定位
oracle分两大块,一块是开发,一块是管理。开发主要是写写存储过程、触发器什么的,还有就是用Oracle的Develop工具做form。有点类似于程序员,需要有较强的逻辑思维和创造能力,个人觉得会比较辛苦,是青春饭J;管理则需要对oracle数据库的原理有深刻的认识,有全局操纵的能力和紧密的思维,责任较大,因为一 ......