sysdba 是系统权限,dba是用户对象权限;
sysdba,是管理oracle实例的,它的存在不依赖于整个数据库完全启动,只要实例启动了,他就已经存在;
以sysdba身份登陆,装载数据库、打开数据库,只有数据库打开了,或者说整个数据库完全启动后,dba角色才有了存在的基础;而且,dba是Oracle里的一种对象,Role 和User一样,是实实在在存在在Oracle里的物理对象,而sysdba是指的一种概念上的操作对象,在Oracle数据里并不存在。
SQL> select * from v$pwfile_users;
USERNAME SYSDB SYSOP SYSAS
------------------------------ ----- ----- -----
SYS TRUE TRUE FALSE
添加一个用户的dba权限
SQL> grant dba to jinlian
2 ;
Grant succeeded.
明确看到系统中有dba的role权限,而且jinlian用户已经是dba,sys也是dba用户
SQL> SELECT * FROM DBA_ROLE_PRIVS WHERE GRANTED_ROLE='DBA';
GRANTEE GRANTED_ROLE ADM DEF
------------------------------ ------------------------------ --- ---
OGG_TS DBA NO YES
SYS DBA YES YES
JINLIAN DBA NO YES
SYSTEM DBA YES YES
查询数据库中是否含有sysdba的角色权限
SQL> SELECT * FROM DBA_ROLE_PRIVS WHERE GRANTED_ROLE LIKE '*DBA*';
no rows selected
SQL> SELECT * FROM DBA_ROLE_PRIVS WHERE GRANTED_ROLE='SYSDBA';
no rows selected
并不存在sysdba的角色权限。查看此时jinlian用户是否是sysdba
SQL> select * from v$pwfile_users;
USERNAME SYSDB SYSOP SYSAS
------------------------------ ----- ----- -----
SYS TRUE TRUE FALSE
依然只有sys,查看orapw密码文件,只有internal(是sys用户)
[oracle@og1 dbs]$ cd /u01/app/oracle/product/11.2.0/dbhome_1/dbs/
[oracle@og1 dbs]$ strings orapwogg1
]\[Z
ORACLE Remote Password file
INTERNAL
AB27B53EDC5FEF41
8A8F025737A9097A
3gM
授予金莲sysdba权限,分别以普通用户和sysdba登陆
SQL> grant sysdba to jinlian;
Grant succeeded.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> conn jinlian/jinlian
Connected.
SQL> show user
USER is "JINLIAN"
SQL> conn jinlian/jinlian as sysdba
Connected.
SQL> show user
USER is "SYS"
以sysdba登陆用户就是sys了,以普通用户登陆还是本身的用户。此时查看密码文件多了jinlian的密码信息
SQL> select * from v$pwfile_users;
USERNAME SYSDB SYSOP SYSAS
------------------------------ ----- ----- -----
SYS TRUE TRUE FALSE
JINLIAN TRUE FALSE FALSE
[oracle@og1 dbs]$ strings orapwogg1
]\[Z
ORACLE Remote Password file
INTERNAL
AB27B53EDC5FEF41
8A8F025737A9097A
3gM
JINLIAN
E8D040CA2EE5FD93
CTe!SZ