oracle 最高角色,Oracle 用户及角色介绍

一.用户管理

1.1建立用户(数据库验证)

CREATEUSERDAVE  IDENTIFIEDBYpwd

DEFAULTTABLESPACE  users

TEMPORARYTABLESPACEtemp

QUOTA  5mONusers;

1.2修改用户

ALTERUSERDAVE QUOTA 0ONSYSTEM;

1.3删除用户

DROPUSERDAVE;

DROPUSERDAVECASCADE;

1.4显示用户信息

SELECT*FROMDBA_USERS

SELECT*FROMDBA_TS_QUOTAS

二.系统权限

系统权限作用

CREATE SESSION连接到数据库

CREATE TABLE建表

CREATE TABLESPACE建立表空间

CREATE VIEW建立视图

CREATE SEQUENCE建立序列

CREATE USER建立用户

系统权限是指执行特定类型SQL命令的权利,用于控制用户可以执行的一个或一类数据库操作。(新建用户没有任何权限)

2.1授予系统权限

GRANTCREATESESSION,CREATE TABLE TO DAVE;

GRANTCREATESESSIONTODAVEWITHADMINOPTION;

选项:ADMIN OPTION使该用户具有转授系统权限的权限。

2.2显示系统权限

查看所有系统权限:

Select * from system_privilege_map;

显示用户所具有的系统权限:

Select * from dba_sys_privs;

显示当前用户所具有的系统权限:

Select * from user_sys_privs;

显示当前会话所具有的系统权限:

Select * from session_privs;

2.3收回系统权限

REVOKECREATETABLEFROMDAVE;

REVOKECREATESESSIONFROMDAVE;

三.角色:

角色是一组相关权限的命名集合,使用角色最主要的目的是简化权限管理。

3.1预定义角色。

CONNECT自动建立,包含以下权限:ALTER SESSION、CREATE CLUSTER、CREATE DATABASELINK、CREATE SEQUENCE、CREATE SESSION、CREATE SYNONYM、CREATE TABLE、CREATEVIEW。

RESOURCE自动建立,包含以下权限:CREATE CLUSTER、CREATE PROCEDURE、CREATE SEQUENCE、CREATE TABLE、CREATE TRIGGR。

3.2显示角色信息,

§ROLE_SYS_PRIVS

§ROLE_TAB_PRIVS

§ROLE_ROLE_PRIVS

§SESSION_ROLES

§USER_ROLE_PRIVS

§DBA_ROLES

四. Oracle用户角色

每个Oracle用户都有一个名字和口令,并拥有一些由其创建的表、视图和其他资源。

Oracle角色(role)就是一组权限(privilege)(或者是每个用户根据其状态和条件所需的访问类型)。用户可以给角色授予或赋予指定的权限,然后将角色赋给相应的用户。一个用户也可以直接给其他用户授权。

数据库系统权限(Database System Privilege)允许用户执行特定的命令集。例如,CREATE TABLE权限允许用户创建表,GRANT ANY PRIVILEGE权限允许用户授予任何系统权限。

数据库对象权限(Database Object Privilege)使得用户能够对各个对象进行某些操作。例如DELETE权限允许用户删除表或视图的行,SELECT权限允许用户通过select从表、视图、序列(sequences)或快照(snapshots)中查询信息。

4.1创建用户

Oracle内部有两个建好的用户:SYSTEM和SYS。用户可直接登录到SYSTEM用户以创建其他用户,因为SYSTEM具有创建别的用户的权限。在安装Oracle时,用户或系统管理员首先可以为自己建立一个用户。例如:

create user user01 identified by u01;

该命令还可以用来设置其他权限。

要改变一个口令,可以使用alter user命令:

alter user user01 identified by usr01;

现在user01的口令已由“u01”改为“usr01”。

除了alter user命令以外,用户还可以使用password命令。如果使用password命令,用户输入的新口令将不在屏幕上显示。有dba特权的用户可以通过password命令改变任何其他用户的口令;其他用户只能改变自己的口令。

当用户输入password命令时,系统将提示用户输入旧口令和新口令,如下所示:

password

Changing password for user01

Old password:

New password:

Retype new password:

当成功地修改了口令时,用户会得到如下的反馈:

Password changed

4.2删除用户

删除用户,可以使用drop user命令,如下所示:

drop user user01;

如果用户拥有对象,则不能直接删除,否则将返回一个错误值。指定关键字CASCADE,可删除用户所有的对象,然后再删除用户。

下面的例子用来删除用户与其对象:

drop user user01 CASCADE;

4.33种标准角色

Oracle为了兼容以前的版本,提供了三种标准的角色(role):CONNECT、RESOURCE和DBA。

4.3.1.CONNECT Role(连接角色)

临时用户,特别是那些不需要建表的用户,通常只赋予他们CONNECT role。CONNECT是使用Oracle的简单权限,这种权限只有在对其他用户的表有访问权时,包括select、insert、update和delete等,才会变得有意义。拥有CONNECT role的用户还能够创建表、视图、序列(sequence)、簇(cluster)、同义词(synonym)、会话(session)和与其他数据库的链(link)。

4.3.2. RESOURCE Role(资源角色)

更可靠和正式的数据库用户可以授予RESOURCE role。RESOURCE提供给用户另外的权限以创建他们自己的表、序列、过程(procedure)、触发器(trigger)、索引(index)和簇(cluster)。

4.3.3. DBA Role(数据库管理员角色)

DBA role拥有所有的系统权限----包括无限制的空间限额和给其他用户授予各种权限的能力。SYSTEM由DBA用户拥有。

一些DBA经常使用的典型权限。

1.grant(授权)命令

grant connect, resource to user01;

2.revoke(撤消)权限

revoke connect, resource from user01;

一个具有DBA角色的用户可以撤消任何别的用户甚至别的DBA的CONNECT、RESOURCE和DBA的其他权限。当然,这样是很危险的,因此,除非真正需要,DBA权限不应随便授予那些不是很重要的一般用户。

撤消一个用户的所有权限,并不意味着从Oracle中删除了这个用户,也不会破坏用户创建的任何表;只是简单禁止其对这些表的访问。其他要访问这些表的用户可以象以前那样地访问这些表。

五、创建角色

除了前面讲到的三种系统角色----CONNECT、RESOURCE和DBA,用户还可以在Oracle创建自己的role。用户创建的role可以由表或系统权限或两者的组合构成。为了创建role,用户必须具有CREATE ROLE系统权限。

5.1创建role

create role STUDENT;

这条命令创建了一个名为STUDENT的role。

5.2对role授权

一旦创建了一个role,用户就可以给他授权。给role授权的grant命令的语法与对对用户的语法相同。在给role授权时,在grant命令的to子句中要使用role的名称,如下所示:

grant select on CLASS to STUDENT;

现在,拥有STUDENT角色的所有用户都具有对CLASS表的select权限。

5.3删除角色

要删除角色,可以使用drop role命令,如下所示:

drop role STUDENT;

指定的role连同与之相关的权限将从数据库中全部删除。

六. oracle sys system用户的区别

sys是Oracle数据库中权限最高的帐号,具有create database的权限,而system没有这个权限,sys的角色是sysdba,system的角色是sysoper。

其余就是他们两个用户共有的权限了:startup/shutdown/dba两个用户都是可以管理的。平时用system来管理数据库就可以了。这个用户的权限对于普通的数据库管理来说已经足够权限了。

七.查看权限和角色

ORACLE中数据字典视图分为3大类,用前缀区别,分别为:USER,ALL和DBA,许多数据字典视图包含相似的信息。

USER_*:有关用户所拥有的对象信息,即用户自己创建的对象信息

ALL_*:有关用户可以访问的对象的信息,即用户自己创建的对象的信息加上其他用户创建的对象但该用户有权访问的信息

DBA_*:有关整个中对象的信息

(这里的*可以为TABLES,INDEXES,OBJECTS,USERS等)。

比如:只知道scott用户的密码,需要查看一下scott的一些信息

7.1、查scott用户的创建时间、用户状态、使用的默认表空间、临时表空间等信息

SQL> conn scott/admin

已连接。

SQL>select * from user_users;

另:select * from all_users;(scott用户可以访问其他数据库用户对信息的用户名)另:select * from all_users;(所有数据库的用户信息,各用户的密码、状态、默认表空间、临时表空间等)

7.2、查看scott用户自己拥有什么角色

SQL> select * from user_role_privs;

USERNAME  GRANTED_ROLE  ADM  DEF  OS_

------------------------------ ------------------------------ --- --- ---

SCOTT        CONNECT      NO     YES      NO

SCOTT        RESOURCE    NO      YES     NO

注:“ADM”表示这个用户是否可以把该具有的角色赋予给其他的用户

另:没有all_role_privs这个视图另:select * from dba_role_privs(所有数据库用户具有哪些角色,这个视图只有dba角色的权限才可以查询)

7.3、查看scott用户自己具有什么的权限

SQL> select * from session_privs;

7.4、查看scott用户具有什么的系统权限呢

SQL>select * from user_sys_privs;

另:没有all_sys_privs视图另:select * from dba_sys_privs;(所有数据库用户、角色所用于的系统权限)

7.5、查看scott用户中,都哪些用户把对象授予给scott用户呢(读取其他用户对象的权限)

SQL>select * from user_tab_privs;

另:select * from all_tab_privs;   select * from dba_tab_privs;

7.6、查看scott用户中拥有的resource角色都具有什么权限呢

SQL> select * from role_sys_privs where role='RESOURCE';

ROLE     PRIVILEGE   ADM

------------------------------ -------------------------------

RESOURCE CREATE SEQUENCE NO

RESOURCE CREATE TRIGGER NO

RESOURCE CREATE CLUSTER NO

RESOURCE CREATE PROCEDURE NO

RESOURCE CREATE TYPE NO

RESOURCE CREATE OPERATOR NO

RESOURCE CREATE TABLE NO

RESOURCE CREATE INDEXTYPE NO

已选择8行。

7.7、scott用户自己拥有多少的表

SQL>select * from user_tables;

另:select * from all_tables;其他用户所拥有的表另:select * from dba_tables;数据库中所有用户的表

7.8、查看scott用户已经使用多大的空间,允许使用的最大空间是多少

SQL> select tablespace_name,bytes,max_bytes from user_ts_quotas;

另:select * from dba_ts_quotas;(所有的数据库用户在每个表空间已使用的空间,最大空间)

7.9、把自己的表赋予给其他用户

SQL>grant select on emp to mzl;

查看都把哪些表什么权限赋予了其他用户

SQL>select * from user_tab_privs_made

7.10、把表的某一列操作权限赋予给其他用户

SQL>grant update(job) on emp to mzl;

注:查看数据库中所有的角色select * form. dba_roles;

7.11、sys授予scott用户dba角色

SQL> conn /as sysdba

已连接。

SQL> grant dba to scott;

授权成功。

另:如果这样

SQL> grant dba to scott with admin option;

授权成功。

scott用户就可以把dba的权限授予给其他的用户了。

7.12 sys回收scott用户的dba角色

SQL> revoke dba from scott;

撤销成功。

八.Oracle用户及作用介绍

http://docs.oracle.com/cd/B28359_01/server.111/b28337/tdpsg_user_accounts.htm

Oracle官方文档对Oracle的用户分成了三类:

(1)     PredefinedAdministrative Accounts

(2)     PredefinedNon-Administrative User Accounts

(3)     PredefinedSample Schema User Accounts

8.1 Predefined Administrative Accounts

A default OracleDatabase installation provides a set of predefined administrative accounts. These are accounts that have specialprivileges required to administer areas of the database, such as the CREATEANY TABLE or ALTER SESSION privilege, or EXECUTE privilegeson packages owned by the SYSschema. The default tablespace foradministrative accounts is either SYSTEM or SYSAUX.

Table 3-1 Predefined Oracle DatabaseAdministrative User AccountsUser AccountDescriptionStatus After InstallationANONYMOUSAccount that allows HTTP access to Oracle XML DB. It is used in place of theAPEX_PUBLIC_USERaccount when the Embedded PL/SQL Gateway (EPG) is installed in the database.

EPG is a Web server that can be used with Oracle Database. It provides the necessary infrastructure to create dynamic applications.Expired and locked

CTXSYSThe account used to administer Oracle Text. Oracle Text enables you to build text query applications and document classification applications. It provides indexing, word and theme searching, and viewing capabilities for text.Expired and locked

DBSNMPThe account used by the Management Agent component of Oracle Enterprise Manager to monitor and manage the database.Open

Password is created at installation or database creation time.

EXFSYSThe account used internally to access theEXFSYSschema, which is associated with the Rules Manager and Expression Filter feature. This feature enables you to build complex PL/SQL rules and expressions. TheEXFSYSschema contains the Rules Manager and Expression Filter DDL, DML, and associated metadata.Expired and locked

LBACSYSThe account used to administer Oracle Label Security (OLS). It is created only when you install the Label Security custom option.Expired and locked

MDSYSThe Oracle Spatial and Oracle Multimedia Locator administrator account.Expired and locked

MGMT_VIEWAn account used by Oracle Enterprise Manager Database Control.Open

Password is randomly generated at installation or database creation time. Users do not need to know this password.

OLAPSYSThe account that owns the OLAP Catalog (CWMLite). This account has been deprecated, but is retained for backward compatibility.Expired and locked

OWBSYSThe account for administrating the Oracle Warehouse Builder repository.

Access this account during the installation process to define the base language of the repository and to define Warehouse Builder workspaces and users. A data warehouse is a relational or multidimensional database that is designed for query and analysis.Expired and locked

ORDPLUGINSThe Oracle Multimedia user. Plug-ins supplied by Oracle and third-party, format plug-ins are installed in this schema.

Oracle Multimedia enables Oracle Database to store, manage, and retrieve p_w_picpaths, audio, video, DICOM format medical p_w_picpaths and other objects, or other heterogeneous media data integrated with other enterprise information.Expired and locked

OUTLNThe account that supports plan stability. Plan stability prevents certain database environment changes from affecting the performance characteristics of applications by preserving execution plans in stored outlines.OUTLNacts as a role to centrally manage metadata associated with stored outlines.Expired and locked

SI_INFORMTN_SCHEMAThe account that stores the information views for the SQL/MM Still Image Standard.Expired and locked

SYSAn account used to perform database administration tasks.Open

Password is created at installation or database creation time.

SYSMANThe account used to perform Oracle Enterprise Manager database administration tasks. TheSYSandSYSTEMaccounts can also perform these tasks.Open

Password is created at installation or database creation time.

SYSTEMA default generic database administrator account for Oracle databases.

For production systems, Oracle recommends creating individual database administrator accounts and not using the genericSYSTEMaccount for database administration operations.Open

Password is created at installation or database creation time.

TSMSYSAn account used for transparent session migration (TSM).Expired and locked

WK_TESTThe instance administrator for the default instance,WK_INST. After you unlock this account and assign this user a password, then you must also update the cached schema password using the administration tool Edit Instance Page.

Ultra Search provides uniform search-and-location capabilities over multiple repositories, such as Oracle databases, other ODBC compliant databases, IMAP mail servers, HTML documents managed by a Web server, files on disk, and more.Expired and locked

WKSYSAn Ultra Search database super-user.WKSYScan grant super-user privileges to other users, such asWK_TEST. All Oracle Ultra Search database objects are installed in theWKSYSschema.Expired and locked

WKPROXYAn administrative account of Oracle9i Application Server Ultra Search.Expired and locked

WMSYSThe account used to store the metadata information for Oracle Workspace Manager.Expired and locked

XDBThe account used for storing Oracle XML DB data and metadata.

Oracle XML DB provides high-performance XML storage and retrieval for Oracle Database data.Expired and locked

8.2 PredefinedNon-Administrative User Accounts

Non-administrativeuser accounts only have the minimum privileges needed to perform their jobs.Their default tablespace is USERS.

Table 3-2 PredefinedOracle Database Non-Administrative User AccountsUser AccountDescriptionStatus After InstallationAPEX_PUBLIC_USERThe Oracle Database Application Express account. Use this account to specify the Oracle schema used to connect to the database through the database access descriptor (DAD).

Oracle Application Express is a rapid, Web application development tool for Oracle Database.Expired and locked

DIPThe Oracle Directory Integration and Provisioning (DIP) account that is installed with Oracle Label Security. This profile is created automatically as part of the installation process for Oracle Internet Directory-enabled Oracle Label Security.Expired and locked

FLOWS_30000The account that owns most of the database objects created during the installation of Oracle Database Application Express. These objects include tables, views, triggers, indexes, packages, and so on.Expired and locked

FLOWS_FILESThe account that owns the database objects created during the installation of Oracle Database Application Express related to modplsql document conveyance, for example, file uploads and downloads. These objects include tables, views, triggers, indexes, packages, and so on.Expired and locked

MDDATAThe schema used by Oracle Spatial for storing Geocoder and router data.

Oracle Spatial provides a SQL schema and functions that enable you to store, retrieve, update, and query collections of spatial features in an Oracle database.Expired and locked

ORACLE_OCMThe account used with Oracle Configuration Manager. This feature enables you to associate the configuration information for the current Oracle Database instance with OracleMetaLink. Then when you log a service request, it is associated with the database instance configuration information.

See Oracle Database Installation Guide for your platform.Expired and locked

SPATIAL_CSW_ADMIN_USRThe Catalog Services for the Web (CSW) account. It is used by Oracle Spatial CSW Cache Manager to load all record-type metadata and record instances from the database into the main memory for the record types that are cached.Expired and locked

SPATIAL_WFS_ADMIN_USRThe Web Feature Service (WFS) account. It is used by Oracle Spatial WFS Cache Manager to load all feature type metadata and feature instances from the database into main memory for the feature types that are cached.Expired and locked

XS$NULLAn internal account that represents the absence of a user in a session. BecauseXS$NULLis not a user, this account can only be accessed by the Oracle Database instance.XS$NULLhas no privileges and no one can authenticate asXS$NULL, nor can authentication credentials ever be assigned toXS$NULL.Expired and locked

8.3 PredefinedSample Schema User Accounts

If you install the sample schemas, which you must doto complete the examples in this guide, Oracle Database creates a set of sampleuser accounts. The sample schema user accounts are all non-administrativeaccounts, and their tablespace is USERS.

Table 3-3 DefaultSample Schema User AccountsUser AccountDescriptionStatus After InstallationBIThe account that owns theBI(Business Intelligence) schema included in the Oracle Sample Schemas.Expired and locked

HRThe account used to manage theHR(Human Resources) schema. This schema stores information about the employees and the facilities of the company.Expired and locked

OEThe account used to manage theOE(Order Entry) schema. This schema stores product inventories and sales of the company's products through various channels.Expired and locked

PMThe account used to manage thePM(Product Media) schema. This schema contains descriptions and detailed information about each product sold by the company.Expired and locked

IXThe account used to manage theIX(Information Exchange) schema. This schema manages shipping through business-to-business (B2B) applications.Expired and locked

SHThe account used to manage theSH(Sales) schema. This schema stores business statistics to facilitate business decisions.Expired and locked

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值