ITPub博客

首页 > 数据库 > Oracle > SYS,SYSTEM,DBA,SYSDBA,SYSOPER的区别与联系

SYS,SYSTEM,DBA,SYSDBA,SYSOPER的区别与联系

原创 Oracle 作者:迷倪小魏 时间:2017-08-07 22:00:58 0 删除 编辑

  
     在脑海中,一直在问什么是SYS?什么是SYSTEM?什么是DBA?什么是SYSDBA?什么是SYSOPER?他们之间究竟有何联系呢?

 

在Oracle数据库中,有SYS,SYSTEM,DBA, SYSDBA,SYSOPER这些用户、角色和权限,那它们之间有什么区别和联系呢?通过查阅相关资料和官方文档,现在基本弄明白,写出来和大家分享:

 

SYS:所有Oracle的数据字典的基表和视图都存放在SYS用户中,这些基表和视图对于Oracle的运行是非常重要的,有数据库自己维护,任何用户都不能手动更改。SYS用户拥有dba,sysdba,sysoper角色和权限,是Oracle权限最高的用户,类似于公司董事长,而SYSTEM用户类似于公司总经理。

 

SYSTEM:用于存放次一级的内部数据,如Oracle的一些特性或工具的管理信息。SYSTEM用户拥有dba角色的权限。

 

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

只有数据库打开了,或者说整个数据库完全启动后,dba角色才有了存在的基础

 

SYSDBA:拥有最高的系统权限,sysdba,是管理oracle实例的,它的存在不依赖于整个数据库完全启动,只要实例启动了,他就已经存在,以sysdba身份登陆,装载数据库、打开数据库

SQL>conn / as sysdba;这时候,其实我们是以SYSDBA这个身份去登陆数据库的,我们当前的default schema是SYS。SYSDBA可以访问V$对象视图

 

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

 

 

以下是Oracle11g官方文档的相关描述:

******************************************************************************************************

The Database Administrator's Operating System Account

To perform many of the administrative duties for a database, you must be able to execute operating system commands. Depending on the operating system on which Oracle Database is running, you might need an operating system account or ID to gain access to the operating system. If so, your operating system account might require operating system privileges or access rights that other database users do not require (for example, to perform Oracle Database software installation). Although you do not need the Oracle Database files to be stored in your account, you should have access to them.

See Also:

Your operating system-specific Oracle documentation. The method of creating the account of the database administrator is specific to the operating system.

 

Administrative User Accounts

Two administrative user accounts are automatically created when Oracle Database is installed:

·        SYS (default password: CHANGE_ON_INSTALL)

·        SYSTEM (default password: MANAGER)

Note:

Both Oracle Universal Installer (OUI) and Database Configuration Assistant (DBCA) now prompt for SYS and SYSTEMpasswords and do not accept the default passwords "change_on_install" or "manager", respectively.

Oracle通过OUI和DBCA安装数据库时,根据提示输入SYS和SYSTEM的密码,不使用其默认密码“change_on_install”或“manager”。

If you create the database manually, Oracle strongly recommends that you specify passwords for SYS and SYSTEM at database creation time, rather than using these default passwords. See "Protecting Your Database: Specifying Passwords for Users SYS and SYSTEM" for more information.

如果你是手动创建数据库,Oracle强烈建议你在创建数据库时指定SYS和SYSTEM的密码,而不是使用默认密码。

Create at least one additional administrative user and grant to that user an appropriate administrative role to use when performing daily administrative tasks. Do not use SYS and SYSTEM for these purposes.

创建至少一个额外的管理用户,并授予该用户在执行日常管理任务时使用的适当管理角色。 而不要使用SYS和SYSTEM。

SYS

When you create an Oracle database, the user SYS is automatically created and granted the DBA role.

在你创建Oracle数据库时,将自动创建用户SYS并授予DBA角色。

All of the base tables and views for the database data dictionary are stored in the schema SYS. These base tables and views are critical for the operation of Oracle Database. To maintain the integrity of the data dictionary, tables in the SYS schema are manipulated only by the database. They should never be modified by any user or database administrator, and no one should create any tables in the schema of user SYS. (However, you can change the storage parameters of the data dictionary settings if necessary.)

数据库中的数据字典的所有基表和视图都存储在模式SYS中。 这些基表和视图对于Oracle数据库的操作至关重要。 为了保持数据字典的完整性,SYS模式中的表仅由数据库操作。任何用户或数据库管理员都不应该修改它们,也不应该在用户SYS的模式中创建任何表。(但是,如果需要,您可以更改数据字典设置的存储参数。)

Ensure that most database users are never able to connect to Oracle Database using the SYS account.

确保大多数数据库用户永远无法使用SYS帐户连接到Oracle数据库。

SYSTEM

When you create an Oracle Database, the user SYSTEM is also automatically created and granted the DBA role.

当你创建Oracle数据库时,用户SYSTEM也将自动创建并授予DBA角色。

The SYSTEM user name is used to create additional tables and views that display administrative information, and internal tables and views used by various Oracle Database options and tools. Never use the SYSTEM schema to store tables of interest to non-administrative users.

SYSTEM用户用于创建显示管理信息的其他表和视图,以及各种Oracle数据库选项和工具使用的内部表和视图。不要使用SYSTEM模式来存储非管理用户的表。

 

[oracle@seiang11g admin]$ rman
Recovery Manager: Release 11.2.0.4.0 - Production on Mon Aug 7 18:45:06 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

RMAN> connect target system/oracle@ORADB11G
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
ORA-01017: invalid username/password; logon denied

RMAN> connect target sys/oracle@ORADB11G
connected to target database: ORADB11G (DBID=3377212249)

 

对于特殊权限,system不能够授予用户,而sys可以

SYS@seiang11g>create user wjq identified by wjq;
User created.

SYSTEM@seiang11g>grant sysoper to wjq;
grant sysoper to wjq
*
ERROR at line 1:
ORA-01031: insufficient privileges

SYSTEM@seiang11g>conn / as sysdba
Connected.
SYS@seiang11g>grant sysoper to wjq;
Grant succeeded.

 

The DBA Role

A predefined DBA role is automatically created with every Oracle Database installation. This role contains most database system privileges. Therefore, the DBA role should be granted only to actual database administrators.

每个Oracle数据库安装都会自动创建预定义的DBA角色。 此角色包含大多数的数据库系统权限。 因此,DBA角色应该授予实际的数据库管理员。

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. These system privileges are discussed in "Administrative Privileges".

DBA角色不包括SYSDBA或SYSOPER系统权限。 这些是特殊的管理权限,允许管理员执行基本的数据库管理任务,例如创建数据库和实例启动和关闭。

 

 

Administrative Privileges

Administrative privileges that are required for an administrator to perform basic database operations are granted through two special system privileges, SYSDBAand SYSOPER. You must have one of these privileges granted to you, depending upon the level of authorization you require.

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系统权限也允许访问数据库实例。 这些权限的控制完全不在数据库本身之外。SYSOPER不能访问v$对象试图。

The SYSDBA and SYSOPER privileges can also be thought of as types of connections that enable you to perform certain database operations for which privileges cannot be granted in any other fashion. For example, if you have the SYSDBA privilege, you can connect to the database by specifying CONNECT AS SYSDBA.

SYSDBA和SYSOPER权限也可以被认为是连接类型,使你能够执行特定的数据库操作,无法以任何其他方式授予权限。 例如,如果你具有SYSDBA权限,则可以通过指定CONNECT AS SYSDBA连接到数据库。

SYS@seiang11g>select * from system_privilege_map where name like '%SYS%';

 PRIVILEGE NAME                                       PROPERTY
---------- ---------------------------------------- ----------
      -3 ALTER SYSTEM                                      0
      -4 AUDIT SYSTEM                                      0
            -83 SYSDBA                                      0
           -84 SYSOPER                                      0

 

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

 

SYSDBA and SYSOPER

The following operations are authorized by the SYSDBA and SYSOPER system privileges:

System Privilege

Operations Authorized

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

Effectively, this system privilege allows a user to connect as user SYS.

SYSOPER

  • 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

This privilege allows a user to perform basic operational tasks, but without the ability to look at user data.

此权限允许用户执行基本的操作任务,但无法查看用户数据。SYSOPER没有权限访问V$对象视图

 

The manner in which you are authorized to use these privileges depends upon the method of authentication that you use.

你被授权使用这些权限的方式取决于您使用的身份验证方法。

When you connect with SYSDBA or SYSOPER privileges, you connect with a default schema, not with the schema that is generally associated with your username. For SYSDBA this schema is SYS; for SYSOPER the schema is PUBLIC.

当你使用SYSDBA或SYSOPER权限连接时,你将连接到默认的schema,而不是通常与用户名相关联的schema。 对于SYSDBA,此schema是SYS; 对于SYSOPER,schema是PUBLIC。

[oracle@seiang11g ~]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.4.0 Production on Mon Aug 7 18:59:10 2017
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
@>conn / as sysdba
Connected.
SYS@seiang11g>
SYS@seiang11g>conn / as sysoper
Connected.
PUBLIC@seiang11g>


在使用
OEM登陆时,还有一种登陆角色的选择,则是normal,这个是对所有普通用户而言,登陆后其schema是自身

 

查看密码文件视图,可以得到哪些用户为sysdba,哪些用户为sysoper
SYS@seiang11g>select * from v$pwfile_users;

USERNAME                       SYSDB SYSOP SYSAS
------------------------------ ----- ----- -----
SYS                            TRUE  TRUE  FALSE
WJQ                            FALSE TRUE  FALSE

 

Connecting with Administrative Privileges: Example

This example illustrates that a user is assigned another schema (SYS) when connecting with the SYSDBA system privilege. Assume that the sample user oe has been granted the SYSDBA system privilege and has issued the following statements:

CONNECT oe

CREATE TABLE admin_test(name VARCHAR2(20));
 

Later, user oe issues these statements:

CONNECT oe AS SYSDBA

SELECT * FROM admin_test;
 

User oe now receives the following error:

ORA-00942: table or view does not exist 
Having connected as SYSDBA, user oe now references the SYS schema, but the table was created in the oe schema.

这两个权限独立于数据库之外,位于数据库密码文件之中,属于密码认证范畴


作者:SEian.G(苦练七十二变,笑对八十一难)


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31015730/viewspace-2143214/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: RMAN完全恢复案例
请登录后发表评论 登录
全部评论

注册时间:2016-03-12

  • 博文量
    101
  • 访问量
    453396