drop role plustrace;
create role plustrace;
grant select on v_$sesstat to plustrace;
grant select on v_$statname to plustrace;
grant select on v_$mystat to plustrace;
grant plustrace to dba with admin option;
检查角色使用情况:
SQL> select role from dba_roles where role = 'PLUSTRACE';
ROLE
----------------
PLUSTRACE
SQL> show user
USER is "SYSTEM"
SQL> @?\rdbms\admin\utlxplan
Table created.
SQL> create public synonym plan_table for system.plan_table;
Synonym created.
SQL> grant select, update, insert, delete on plan_table to <你的用户名>;
Grant succeeded.
SQL> grant plustrace to <你的用户名>;
Grant succeeded.
我们的例子中使用的用户是HR(可以在Oracle提供的样本方案中找到)。
SQL> conn hr/hr
Connected.
SQL> set autotrace on
SQL> select * from dual;
D
-
X
select d.department_id,
d.department_name,
r.region_name
from departments d,
locations l,
countries c, regions r
where d.location_id=l.location_id
and l.country_id=c.country_id
and c.region_id=r.region_id;
和
select department_id,
department_name,
region_name
from departments natural join locations
natural join countries natural join regions;
SQL> update cost_example
2 set region_name = 'Asia'
3 where region_name = 'Europe';
set region_name = 'Asia'
*
ERROR at line 2:
ORA-01779: cannot modify a column which maps to a non key-preserved table
DEPARTMENT_NAME字段的值能被修改吗?
SQL> update cost_example
2 set department_name = 'PR'
3 where department_name = 'Public Relations';
1 row updated.