sys@ORCL> conn /as sysdba 已连接。 sys@ORCL> grant read,write on directory exp_dir to u2; 授权成功。 sys@ORCL> grant read,write on directory exp_dir to u1; 授权成功。 sys@ORCL> grant dba to u2; sys@ORCL> grant dba to u1; 授权成功。 |
directory目录前面已经创建了,授权给用户u1、u2。而且用户u1、u2需要拥有dba权限。
sys@ORCL> conn u2/u2 已连接。 u2@ORCL> select count(*) from t; COUNT(*) ---------- 1 u2@ORCL> conn u1/u1 已连接。 u1@ORCL> select count(*) from t; select count(*) from t * 第 1 行出现错误: ORA-00942: 表或视图不存在 |
可以看见u1下面是不可以执行t表的查询的,现在我们就把u2下面的这个sql用例导入到u1用户下。
导出:
u2@ORCL> conn u2/u2 已连接。 u2@ORCL> declare mycase clob; 2 begin dbms_sqldiag.export_sql_testcase(directory => 'EXP_DIR',sql_text => 'select count(*) from t',user_name => 'U2',exportData => true,testcase => mycase); 4 end; 5 / PL/SQL 过程已成功完成。 |