SYS,SYSTEM,DBA,SYSDBA,SYSOPER的區別與聯絡

迷倪小魏發表於2017-08-07

  
     在腦海中,一直在問什麼是SYS?什麼是SYSTEM?什麼是DBA?什麼是SYSDBA?什麼是SYSOPER?他們之間究竟有何聯絡呢?

 

在中,有SYS,SYSTEM,DBA, SYSDBA,SYSOPER這些使用者、角色和許可權,那它們之間有什麼區別和聯絡呢?透過查閱相關資料和官方文件,現在基本弄明白,寫出來和大家分享:

 

SYS所有Oracle的資料字典的基表和檢視都存放在SYS使用者中,這些基表和檢視對於Oracle的執行是非常重要的,有資料庫自己維護,任何使用者都不能手動更改。SYS使用者擁有dbasysdbasysoper角色和許可權,是Oracle許可權最高的使用者,類似於公司董事長,而SYSTEM使用者類似於公司總經理。

 

SYSTEM用於存放次一級的內部資料,如Oracle的一些特性或工具的管理資訊。SYSTEM使用者擁有dba角色的許可權。

 

DBAOracle資料庫裡面其實只是一個角色(role)。那麼什麼是角色呢?可以簡單的認為一個角色就是某些個許可權的集合體,也就是說把多個系統許可權(system privilege),物件許可權(object privilege)以及角色(role)揉和在一起,然後賦給一個角色。說白了,Oracle引入角色的概念,其實是為了避免相關的系統許可權和物件許可權的賦予和回收的複雜性。把一堆系統許可權和物件許可權以及角色打包之後賦給某個新角色,然後再對這個新角色進行必要的操作就顯得相當便捷和方便了。當然,在Oracle裡面一個角色是可以賦給另外一個角色的,但是角色的賦給是不能夠構成迴圈迴路的。例如:先把role1role2,然後把role2role3,那麼你就不可以再把role3role1了。這是Oracle不允許的!

只有資料庫開啟了,或者說整個資料庫完全啟動後,dba角色才有了存在的基礎

 

SYSDBA擁有最高的系統許可權,sysdba,是管理oracle例項的,它的存在不依賴於整個資料庫完全啟動,只要例項啟動了,他就已經存在,以sysdba身份登陸,裝載資料庫、開啟資料庫

SQL>conn / as sysdba;這時候,其實我們是以SYSDBA這個身份去登陸資料庫的,我們當前的default schemaSYSSYSDBA可以訪問V$物件檢視

 

SYSOPER也是一種系統許可權,只不過跟SYSOPER略有區別而已。SQL>conn /as sysoper 這種連線下,我們的default schemaPUBLIC

 

 

以下是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透過OUIDBCA安裝資料庫時,根據提示輸入SYSSYSTEM的密碼,不使用其預設密碼“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  for more information.

如果你是手動建立資料庫,Oracle強烈建議你在建立資料庫時指定SYSSYSTEM的密碼,而不是使用預設密碼。

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.

建立至少一個額外的管理使用者,並授予該使用者在執行日常管理任務時使用的適當管理角色。 而不要使用SYSSYSTEM

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 .

DBA角色不包括SYSDBASYSOPER系統許可權 這些是特殊的管理許可權,允許管理員執行基本的資料庫管理任務,例如建立資料庫和例項啟動和關閉。

 

 

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.

即使資料庫未開啟,SYSDBASYSOPER系統許可權也允許訪問資料庫例項。 這些許可權的控制完全不在資料庫本身之外。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.

SYSDBASYSOPER許可權也可以被認為是連線型別,使你能夠執行特定的資料庫操作,無法以任何其他方式授予許可權。 例如,如果你具有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

 

不要輕易將SYSDBASYSOPER這兩種系統許可權授權給資料庫的普通使用者。也不要輕易將DBA角色賦給普通使用者。在對資料庫進行普通操作的時候,也不要以SYSDBASYSOPER登入!!!

 

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.

當你使用SYSDBASYSOPER許可權連線時,你將連線到預設的schema,而不是通常與使用者名稱相關聯的schema 對於SYSDBA,此schemaSYS; 對於SYSOPERschemaPUBLIC

[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部落格 ” ,連結:http://blog.itpub.net/31015730/viewspace-2143214/,如需轉載,請註明出處,否則將追究法律責任。

相關文章