此多媒体陈列厅包含 23 张图像。
数据库软件安装过程 dbca运行过程 sqlplus执行 Oracle 8i完整 … 继续阅读
一、执行的schema不同,操作的对象也不同
C:\Users\XIFENFEI>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on 星期日 11月 20 20:39:06 20
Copyright (c) 1982, 2010, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Productio
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options
SQL> create user xffa identified by xifenfei;
用户已创建。
SQL> grant connect,resource to xffa;
授权成功。
SQL> create user xffb identified by xifenfei;
用户已创建。
SQL> grant connect,resource to xffb;
授权成功。
SQL> conn xffa/xifenfei
已连接。
xffa>create table tmp(str varchar2(50));
表已创建。
xffa>insert into tmp values
2 ('my name is xffa');
已创建 1 行。
xffa>commit;
提交完成。
xffa>create or replace procedure definer_proc as
2 begin
3 for x in (select sys_context('userenv', 'current_user') current_user,
4 sys_context('userenv', 'session_user') session_user,
5 sys_context('userenv', 'current_schema') current_sch
ema,
6 str
7 from tmp) loop
8 dbms_output.put_line('Current User: ' || x.current_user);
9 dbms_output.put_line('Session User: ' || x.session_user);
10 dbms_output.put_line('Current Schema: ' || x.current_schema);
11 dbms_output.put_line('Tables Value: ' || x.str);
12 end loop;
13 end;
14 /
过程已创建。
xffa>create or replace procedure invoker_proc AUTHID CURRENT_USER as
2 begin
3 for x in (select sys_context('userenv', 'current_user') current_user,
4 sys_context('userenv', 'session_user') session_user,
5 sys_context('userenv', 'current_schema') current_sch
ema,
6 str
7 from tmp) loop
8 dbms_output.put_line('Current User: ' || x.current_user);
9 dbms_output.put_line('Session User: ' || x.session_user);
10 dbms_output.put_line('Current Schema: ' || x.current_schema);
11 dbms_output.put_line('Tables Value: ' || x.str);
12 end loop;
13 end;
14 /
过程已创建。
xffa>grant execute on definer_proc to xffb;
授权成功。
xffa>grant execute on invoker_proc to xffb;
授权成功。
xffa>set serveroutput on
xffa>exec definer_proc;
Current User: XFFA
Session User: XFFA
Current Schema: XFFA
Tables Value: my name is xffa
PL/SQL 过程已成功完成。
xffa>exec invoker_proc;
Current User: XFFA
Session User: XFFA
Current Schema: XFFA
Tables Value: my name is xffa
PL/SQL 过程已成功完成。
xffa>conn xffb/xifenfei
已连接。
xffb>exec xffa.definer_proc;
PL/SQL 过程已成功完成。
xffb>set serveroutput on
xffb>exec xffa.definer_proc;
Current User: XFFA
Session User: XFFB
Current Schema: XFFA
Tables Value: my name is xffa
PL/SQL 过程已成功完成。
--除了session是当前用户的,其他都是这个过程所属用户
xffb>exec xffa.invoker_proc;
BEGIN xffa.invoker_proc; END;
*
第 1 行出现错误:
ORA-00942: 表或视图不存在
ORA-06512: 在 "XFFA.INVOKER_PROC", line 3
ORA-06512: 在 line 1
--根据这个提示,很容易知道是tmp表不存在,也就是说明这个没有调用xffa.tmp表
xffb>create table tmp(str varchar2(50));
表已创建。
xffb>insert into tmp values
2 ('my name is xffb');
已创建 1 行。
xffb>commit;
提交完成。
xffb>exec xffa.invoker_proc;
Current User: XFFB
Session User: XFFB
Current Schema: XFFB
Tables Value: my name is xffb
PL/SQL 过程已成功完成。
--这个可以看出当时调用者的时候,执行的完全是当前用户下面的对象
在定义者(definer)权限下,执行的用户操作的schema为定义者,所操作的对象是定义者在编译时指定的对象。
在调用者(invoker)权限下,执行的用户操作的schema为当前用户,所操作的对象是当前模式下的对象。
二、执行的权限不同
xffb>create or replace procedure createtbl_definer as
2 begin
3 execute immediate 'create table xff_definer (id number)';
4 end;
5 /
过程已创建。
xffb>create or replace procedure createtbl_invoker AUTHID CURRENT_USER as
2 begin
3 execute immediate 'create table xff_invoker (id number)';
4 end;
5 /
xffb>grant execute on createtbl_definer to xffa;
授权成功。
xffb>grant execute on createtbl_invoker to xffa;
授权成功。
xffb>exec createtbl_definer;
BEGIN createtbl_definer; END;
*
第 1 行出现错误:
ORA-01031: 权限不足
ORA-06512: 在 "XFFB.CREATETBL_DEFINER", line 3
ORA-06512: 在 line 1
--提示权限不足,很明显是缺少创建表的权限
xffb>exec createtbl_invoker;
PL/SQL 过程已成功完成。
xffb>desc xff_invoker;
名称 是否为空? 类型
----------------------------------------- -------- ----------------------------
ID NUMBER
--调用者创建成功
xffb>conn xffa/xifenfei
已连接。
xffa>exec xffb.createtbl_definer;
BEGIN xffb.createtbl_definer; END;
*
第 1 行出现错误:
ORA-01031: 权限不足
ORA-06512: 在 "XFFB.CREATETBL_DEFINER", line 3
ORA-06512: 在 line 1
--定义者同样提示没有权限创建表,通过1中的试验,我们知道
--定义者执行的这个过程定义者的对象,也就是说,是因为xffb无权创建表导致该提示
xffa>exec xffb.createtbl_invoker;
PL/SQL 过程已成功完成。
xffa>desc xff_invoker;
名称 是否为空? 类型
----------------------------------------- -------- ----------------------------
ID NUMBER
xffa>conn / as sysdba
已连接。
SQL>select owner,table_name from dba_tables where table_name=upper('xff_invoker');
OWNER TABLE_NAME
------------------------------ ------------------------------
XFFB XFF_INVOKER
XFFA XFF_INVOKER
--xffa用户执行成功,并且在自己的schema下面创建了表,证明了1的正确
SQL>GRANT CREATE TABLE TO XFFB;
授权成功。
SQL>conn xffb/xifenfei
已连接。
xffb>exec createtbl_definer;
PL/SQL 过程已成功完成。
xffb>desc xff_definer;
名称 是否为空? 类型
----------------------------------------- -------- ----------------------------
ID NUMBER
--说明直接授权是的定义者操作成功,但是角色(resource)不能使其操作成功
xffb>conn xffa/xifenfei
已连接。
xffa>exec xffb.createtbl_definer;
BEGIN xffb.createtbl_definer; END;
*
第 1 行出现错误:
ORA-00955: 名称已由现有对象使用
ORA-06512: 在 "XFFB.CREATETBL_DEFINER", line 3
ORA-06512: 在 line 1
--因为定义者执行的是过程创建者的对象,因为XFFB.CREATETBL_DEFINER已经创建成功
在定义者(definer)权限下,当前用户的权限为角色无效情况下所拥有的权限。
在调用者(invoker)权限下,当前用户的权限为当前所拥有的权限(含角色)。
三、执行的效率不同
在定义者(definer)权限下,过程被静态编译静态执行(相对而言),所执行sql语句在共享区池中是可被共享使用的
在调用者(invoker)权限下,过程静态编译,但动态执行,虽然执行的语句相同,但不同用户执行,其sql语句在共享池中并不能共享。
参考:http://www.itpub.net/thread-935634-1-1.html
1、现象重现
RMAN> shutdown immediate database dismounted Oracle instance shut down RMAN> startup connected to target database (not started) Oracle instance started database mounted RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of startup command at 11/18/2011 14:40:40 ORA-01157: cannot identify/lock data file 11 - see DBWR trace file ORA-01110: data file 11: '/opt/oracle/oradata/test/xifenfei03.dbf' RMAN> restore datafile 11; Starting restore at 2011-11-18 14:41:04 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=157 devtype=DISK channel ORA_DISK_1: restoring datafile 00011 input datafile copy recid=13 stamp=767543949 filename=/tmp/11.dbf destination for restore of datafile 00011: /opt/oracle/oradata/test/xifenfei03.dbf ORA-19505: failed to identify file "/tmp/11.dbf" ORA-27037: unable to obtain file status Linux-x86_64 Error: 2: No such file or directory Additional information: 3 ORA-19600: input file is datafile-copy 13 (/tmp/11.dbf) ORA-19601: output file is datafile 11 (/opt/oracle/oradata/test/xifenfei03.dbf) failover to previous backup channel ORA_DISK_1: starting datafile backupset restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set restoring datafile 00011 to /opt/oracle/oradata/test/xifenfei03.dbf channel ORA_DISK_1: reading from backup piece /tmp/test_full_01mrkqdh_1_1 channel ORA_DISK_1: restored backup piece 1 piece handle=/tmp/test_full_01mrkqdh_1_1 tag=TAG20111114T124433 channel ORA_DISK_1: restore complete, elapsed time: 00:00:02 Finished restore at 2011-11-18 14:41:08
虽然整个过程datafile 11恢复成功了,但是在恢复过程中,先是去读取/tmp/11.dbf的copy文件,读取这个文件失败,然后继续使用/tmp/test_full_01mrkqdh_1_1来恢复数据文件,为什么会出现这样的情况呢?
2、原因分析
RMAN> list copy of datafile 11;
List of Datafile Copies
Key File S Completion Time Ckp SCN Ckp Time Name
------- ---- - ------------------- ---------- ------------------- ----
13 11 A 2011-11-18 14:39:09 11517136 2011-11-14 12:44:33 /tmp/11.dbf
--确实存在datafile 11的copy文件/tmp/11.dbf,并且有效
--checkpoint time为:2011-11-14 12:44:33,创建时间为:2011-11-18 14:39:09
RMAN> list backup of datafile 11;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
1 Full 9.32G DISK 00:04:24 2011-11-14 12:48:57
BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20111114T124433
Piece Name: /tmp/test_full_01mrkqdh_1_1
List of Datafiles in backup set 1
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ------------------- ----
11 Full 11517136 2011-11-14 12:44:33 /opt/oracle/oradata/test/xifenfei03.dbf
--backupset中也有datafile 11
--checkpoint time为:2011-11-14 12:44:33,创建时间为:2011-11-14 12:48:57
--通过比较这两个关于datafile 11的备份时间,rman自动选择了创建时间比较新的备份恢复
RMAN> crosscheck copy of datafile 11;
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=157 devtype=DISK
validation failed for datafile copy
datafile copy filename=/tmp/11.dbf recid=13 stamp=767543949
Crosschecked 1 objects
RMAN> list copy of datafile 11;
List of Datafile Copies
Key File S Completion Time Ckp SCN Ckp Time Name
------- ---- - ------------------- ---------- ------------------- ----
13 11 X 2011-11-18 14:39:09 11517136 2011-11-14 12:44:33 /tmp/11.dbf
--通过检测发现/tmp/11.dbf是无效的,所以rman继续使用backupset进行恢复datafile 11
在有些时候,当rman对中关于一个对象的备份有多个(备份时间不一致),rman会从最新备份的开始还原,如果第一个失败,使用下一个备份,但是在有些时候可能第一个失败后,rman不自动使用下一个,这个时候的处理思路是:使用crosscheck backup/copy检测无效的备份,删除掉,继续执行
17813235971 |
QQ 咨询 |