分类: Oracle
2012-04-17 20:29:16
看看下面的实例:
以sys账户连接数据库:
SQL> conn sys/test as sysdba;
Connected to Oracle9i Enterprise Edition Release 9.2.0.1.0
Connected as SYS
下列查询说明现在只有sys账户拥有sysdba与sysoper的权限。
SQL> select * from v$pwfile_users;
USERNAME SYSDBA SYSOPER
------------------------------ ------ -------
SYS TRUE TRUE
创建新用户test:
SQL> create user test identified by test
2 default tablespace users
3 temporary tablespace temp
4 quota unlimited on users;
User created
授予其连接及修改用户权限:
SQL> grant create session,alter user to test;
Grant succeeded
下列查询再次说明现在只有sys账户拥有sysdba与sysoper的权限。
SQL> select * from v$pwfile_users;
USERNAME SYSDBA SYSOPER
------------------------------ ------ -------
SYS TRUE TRUE
以用户test连接数据库:
SQL> conn test/test;
Connected to Oracle9i Enterprise Edition Release 9.2.0.1.0
Connected as test
修改数据库超级用户sys的密码:
SQL> alter user sys identified by abc;
User altered
sys账户以修改后的密码连接数据库,说明修改成功。
SQL> conn sys/abc as sysdba
Connected to Oracle9i Enterprise Edition Release 9.2.0.1.0
Connected as SYS
所有操作完成并且成功后,下列查询最后说明现在仍然只有sys账户拥
有sysdba与sysoper的权限。
SQL> select * from v$pwfile_users;
USERNAME SYSDBA SYSOPER
------------------------------ ------ -------
SYS TRUE TRUE
总结如下:
1、默认情况下,只要用户具有alter user的权限,那么可以修改
oracle中任意用户,包括alter user中的所有optional。
接上例:
SQL> conn test/test
Connected to Oracle9i Enterprise Edition Release 9.2.0.1.0
Connected as test
SQL> alter user zgh default tablespace system
2 quota 20m on system;
User altered
SQL> alter user zgh default tablespace users
2 quota unlimited on users;
User altered
2、默认情况下,system账户之所以能修改sys的密码,是因为它属于dba角色,
而dba角色当然具有alter user权限。
3、所谓最高权限,在默认情况下,sys账户具有sysdba权限,是oracle中的超级用户,
所以以sys as sysdba登录后,几乎可以在数据库中作任何操作。且sysdba权限不要
轻易授权其它用户,否则会给数据库安全带来问题。
4、system账户默认情况下属于dba角色,它的权限仅次于sys账户。
在Oracle中查看用户权限;
查看用户系统权限:
select * from dba_sys_privs;
select * from all_sys_privs;
select * from user_sys_privs;
查看用户对象权限:
select * from dba_tab_privs;
select * from all_tab_privs;
select * from user_tab_privs;
查看所有角色:
select * from dba_roles;
查看用户所拥有的角色:
select * from dba_role_privs;
select * from user_role_privs;