Oracle dead lock deep research.
Update SQLS will lead dead lock exception. Because by default, it use optimistic lock but not pessimistic lock.
Below description is exceprted from the attachment(It exceeds my image that this blog can not upload the attachment,hehe)
Optimistic locking offers an elegant solution to the problems outlined above. Optimistic locking does
not lock records when they are read, and proceeds on the assumption that the data being updated has not
changed since the read. Since no locks are taken out during the read, it doesn’t matter if the user goes to
lunch after starting a transaction, and deadlocks are all but eliminated since users should never have to
wait on each other’s locks
There are some ways to resolve this problem.
1. Create a pessimistic lock. Change the sql like below formal.
First: select … from … for update nowait
Second: update the resultSet.
2. Execute the SQL again after a random duration when program meets this kind of exception. (It will consume lot of db server resource. I don't think it is the better way)
3. Schedule the SQL executed sequenced or split data without interfere.
相关文档:
我的myeclipse是6.5版, oracle是10.2.0.1的中文版.
myeclipse启动是英文的,DB Browser死活连不上oracle,报两个错误(具体不记得了).后来看了如下文章,知道了原因。
---------------------------------------------------------------------------------------------------------------------------
Hi,
a ......
数据库数据
ID
UserName
Date
1
User1
2010/4/27
1
User1
2010/4/11
1
User1
2010/4/1
要求:
获取最新日期的一条数据
Sql语句:
select t.* from tb t where date = (select max(date) from tb where id = t.id) order by t.id ......
oracle grant
授权语句--select * from dba_users; 查询数据库中的所有用户
--alter user TEST_SELECT account lock; 锁住用户
--alter user TEST_SELECT account unlock; 给用户解锁
--create user xujin identified by xujin; 建立用户
--grant create tablespace to xujin; 授权
--grant select ......
查询星期几:
select to_char(sysdate,'day') from dual;
查询几号:
select to_char(sysdate,'dd') from dual;
查询小时数:
select to_char(sysdate,'hh24') from dual;
查询时间:
select to_char(sysdate,'hh24:mi:ss') from dual;
查询日期时间:
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;
查 ......