DBA,SYSDBA,SYSOPER三者的区别

什么是DBA?什么是SYSDBA,什么又是SYSOPER?三者究竟有何联系呢?

在Oracle数据库领域里,很多Oracle初学者(Me 2)很容易被这三个术语迷惑,就其原因还是基础概念没有弄清楚。记得自己刚开始接触Oracle的时候,也是云里雾里,现在基本弄明白,故写出来和大家分享:

DBA:在Oracle数据库里面其实只是一个角色(role)。那么什么是角色呢?可以简单的认为一个角色就是某些个权限的集合体,也就是说把多个系统权限(system privilege),对象权限(object privilege)以及角色(role)揉和在一起,然后赋给一个角色。说白了,Oracle引入角色的概念,其实是为了避免相关的系统权限和对象权限的赋予和回收的复杂性。把一堆系统权限和对象权限以及角色打包之后赋给某个新角色,然后再对这个新角色进行必要的操作就显得相当便捷和方便了。当然,在Oracle里面一个角色是可以赋给另外一个角色的,但是角色的赋给是不能够构成循环回路的。eg:先把role1给role2,然后把role2给role3,那么你就不可以再把role3给role1了。这是Oracle不允许的,其实你也不可以成功执行这样的包含回路角色的授权的!

SYSDBA:说白了就是一种系统权限而已,没有什么神秘的。当我们在SQL*PLUS命令行上执行了类似如下的操作:

SQL>conn / as sysdba;这时候,其实我们是以SYSDBA这个身份去登陆数据库的,我们当前的default schema是SYS。那么SYSDBA这个系统权限究竟允许执行哪些操作呢?

■   Perform STARTUP and SHUTDOWN operations
■   ALTER DATABASE: open, mount, back up, or change character set
■   CREATE DATABASE
■   DROP DATABASE
■   CREATE SPFILE
■   ALTER DATABASE ARCHIVELOG
■   ALTER DATABASE RECOVER
■   Includes the RESTRICTED SESSION privilege

■   Perform STARTUP and SHUTDOWN operations

■   ALTER DATABASE: open, mount, back up, or change character set

■   CREATE DATABASE

■   DROP DATABASE

■   CREATE SPFILE

■   ALTER DATABASE ARCHIVELOG

■   ALTER DATABASE RECOVER

■   Includes the RESTRICTED SESSION privilege

以SYSDBA登陆Oracle数据库时,上述几种操作是允许执行的。

SYSOPER:也是一种系统权限,只不过跟SYSOPER略有区别而已。SQL>conn /as sysoper 这种连接下,我们的default schema是PUBLIC.允许执行的操作如下:

■ Perform STARTUP and SHUTDOWN operations

■ CREATE SPFILE

■ ALTER DATABASE OPEN/MOUNT/BACKUP

■ ALTER DATABASE ARCHIVELOG

■ ALTER DATABASE RECOVER (Complete recovery only. Any form of incomplete recovery, such as UNTIL

TIME|CHANGE|CANCEL|CONTROLFILE requires connecting as SYSDBA.)

■ Includes the RESTRICTED SESSION privilege

简单区别如下:

SQL> conn sys/oracle as sysdba;

Connected to an idle instance.

SQL> show user;

USER is “SYS”

SQL> conn sys/oracle as sysoper;

Connected to an idle instance.

SQL> show user;

USER is “PUBLIC”

SQL>

Note: The SYSDBA and SYSOPER system privileges allow access to a database instance even when the database is not open. Control of these privileges is totally outside of the database itself.

SYSDBA和SYSOPER系统权限允许我们在数据库打开之前以这两种身份去访问实例。

当然,DBA还可以理解成另外两个术语的简写;Database Administrator,Data Block Address。

一句话总结三者之间的关系:

Note: The DBA role does not include the SYSDBA or SYSOPER system privileges. These are special administrative privileges that allow an administrator to perform basic database administration tasks, such as creating the database and instance startup and shutdown.

DBA 角色并未包含SYSDBA,SYSOPER这两个系统权限。他们是一类特殊的系统管理权限,允许管理员以这两种身份对数据库进行特殊的管理工作。

还有就是,不要轻易将SYSDBA,SYSOPER这两种系统权限授权给数据库的普通用户。也不要轻易将DBA角色赋给普通用户。在对数据库进行普通操作的时候,也不要以SYSDBA,SYSOPER登录。

What is the schema ?

A schema is a collection of database objects owned by a specific database user,or schema objects.Schema has the same name as that user,every user has a single schema,so the two terms(Schema,User) are synonymous.

Schema objects include the segments(tables,indexes..etc) as we can see in the tablespaces as well as the nosegments database objects(constraints,views,procedures,synonyms and packages).But the roles,tablespaces,profiles and directories are not schema objects,cause they are not owned by one specific user.

In a word,if any object(table,view,index…) owned by one user,it’s schema object.Contrarily,the role,profile,tablespace and directory (not owned by one user) are not schema objects.

Note:

There is no relationship between schemas and tablespaces: a tablespace can contain objects from different schemas,and the objects for a schema can be contained in different tablespaces.

objects from different schemas, and the objects for a schema can be contained in
different tablespaces.