Archive for 二月, 2009
星期二, 二月 17th, 2009
我们接着来看下DELETE过程中的锁的情况。
创建测试用表
SQL> CREATE TABLE sunwg(id NUMBER,name VARCHAR2(10))
2 PARTITION BY RANGE(id)
3 (PARTITION p1 VALUES less than(10),
4 PARTITION p2 VALUES less than(20));
Table created
SQL> INSERT INTO sunwg VALUES(1,'tom');
1 row inserted
SQL> COMMIT;
Commit complete
SQL> INSERT INTO sunwg VALUES(11,'mary');
1 row inserted
SQL> COMMIT;
SQL> SELECT * FROM sunwg;
ID NAME
---------- ----------
1 tom
11 mary
测试一:DELETE FROM ...
Posted in oracle | No Comments »
星期一, 二月 16th, 2009
以前对ORACLE中的锁并没有仔细的思考过,仅仅就是应付工作而已。
ORACLE中的锁是比较复杂的,值得好好研究一下。
以后有时间的话我会学习下ORACLE中的锁,今天是第一部分,INSERT过程中的锁。
创建测试用表
SQL> CREATE TABLE sunwg(id NUMBER,name VARCHAR2(10))
2 PARTITION BY RANGE(id)
3 (PARTITION p1 VALUES less than(10),
4 PARTITION p2 VALUES less than(20));
Table created
SQL> CREATE TABLE sunwg_p1(id NUMBER,name VARCHAR2(10));
Table created
SQL> INSERT INTO sunwg_p1 VALUES(1,'tom');
1 row inserted
SQL> COMMIT;
Commit complete
SQL> CREATE TABLE sunwg_p2(id NUMBER,name VARCHAR2(10));
Table created
SQL> INSERT INTO sunwg_p1 VALUES(11,'mary');
1 row inserted
SQL> COMMIT;
Commit complete
测试一:INSERT ... VALUES ...
Posted in oracle | No Comments »
星期一, 二月 16th, 2009
在ORACLE对分区表的操作过程中有时候会出现ORA-14401错误。
admin@dw_jumpcn:/home/admin/sql_turn>oerr ora 14400
14400, 00000, "inserted partition key does not map to any partition"
// *Cause: An attempt was made to insert a record into, a Range or Composite
// Range object, with a concatenated partition key that is beyond
// ...
Posted in oracle | No Comments »
星期四, 二月 12th, 2009
以前很少写SHELL脚本,这是前两天写的。嘿嘿
一共是四台服务器,要分别查看每台机器的负载,当负载大于10的时候要将正在执行的SQL取出来。
#!/bin/sh
. /home/sunwg/.bash_profile
echo " " >>monitor_result.log
echo "##############################" >> monitor_result.log
echo `date +%Y%m%d--%R:%S` >> monitor_result.log
echo >> monitor_result.log
#check dbrac1
echo "dbrac1 result" >>monitor_result.log
l_uptime=`uptime`
echo $l_uptime >> monitor_result.log
l_load=`echo $l_uptime | awk -F: '{print $5}'|awk -F, '{print $1}'|awk -F. '{print $1}'`
if [ $l_load -ge 10 ]; then
sqlplus -s test/test @/home/sunwg/sunwg/check_sql_01.sql >> monitor_result.log
fi
#check dbrac2
echo "dbrac2 result" >>monitor_result.log
l_uptime=`ssh ...
Posted in linux and unix | No Comments »
星期三, 二月 11th, 2009
如果没有基表的访问权限,那么查看视图的执行计划会报ORA-01039.
祥见:ORA-01039
但是在有的时候为了数据安全的原因,不能把基表的权限开放出来。这个时候可以通过SQL Tuning Advisor来解决这个问题。
SUNWG用户
SQL> create table sunwg as select * from dba_objects;
表已创建。
SQL> create view v_sunwg as select * from sunwg;
视图已创建。
SQL> grant select on v_sunwg to hr;
授权成功。
HR用户
SQL> set autot traceonly exp
SQL> select * from sunwg.v_sunwg;
执行计划
---------------------------------------------------------
ERROR:
ORA-01039: 视图基本对象的权限不足
SP2-0612: 生成 AUTOTRACE EXPLAIN 报告时出错
不出所料,又出现了ORA-01039这个讨厌的错误。
看看SQL Tuning Advisor有什么能耐。
SUNWG用户
SQL> grant advisor to hr;
授权成功。
HR用户
SQL> declare
2
3 ...
Posted in oracle | No Comments »