Oracle 用户及角色 介绍_第1页
Oracle 用户及角色 介绍_第2页
Oracle 用户及角色 介绍_第3页
Oracle 用户及角色 介绍_第4页
Oracle 用户及角色 介绍_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、精选文档Oracle 用户及角色 介绍 一. 用户管理1.1 建立用户(数据库验证)CREATE USER DAVE IDENTIFIED BY pwdDEFAULT TABLESPACE usersTEMPORARY TABLESPACE tempQUOTA 5m ON users;1.2 修改用户ALTER USER DAVE QUOTA 0 ON SYSTEM;1.3 删除用户DROP USER DAVE; DROP USER DAVE CASCADE;1.4 显示用户信息SELECT * FROM DBA_USERSSELECT * FROM DBA_TS_QUOTAS二.系统权限系统

2、权限作用CREATE SESSION连接到数据库CREATE TABLE建表CREATE TABLESPACE建立表空间CREATE VIEW建立视图CREATE SEQUENCE建立序列CREATE USER建立用户系统权限是指执行特定类型SQL命令的权利,用于把握用户可以执行的一个或一类数据库操作。(新建用户没有任何权限)2.1 授予系统权限GRANT CREATE SESSION,CREATE TABLE TO DAVE; GRANT CREATE SESSION TO DAVE WITH ADMIN OPTION; 选项:ADMIN OPTION 使该用户具有转授系统权限的权限。2.2

3、 显示系统权限查看全部系统权限:Select * from system_privilege_map;显示用户所具有的系统权限:Select * from dba_sys_privs;显示当前用户所具有的系统权限:Select * from user_sys_privs;显示当前会话所具有的系统权限:Select * from session_privs;2.3 收回系统权限REVOKE CREATE TABLE FROM DAVE;REVOKE CREATE SESSION FROM DAVE;三 .角色:角色是一组相关权限的命名集合,使用角色最主要的目的是简化权限管理。3.1 预定义角色。

4、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_

5、PRIVS§SESSION_ROLES§USER_ROLE_PRIVS§DBA_ROLES四. Oracle用户角色每个Oracle用户都有一个名字和口令,并拥有一些由其创建的表、视图和其他资源。Oracle角色(role)就是一组权限(privilege)(或者是每个用户依据其状态和条件所需的访问类型)。用户可以给角色授予或赐予指定的权限,然后将角色赋给相应的用户。一个用户也可以直接给其他用户授权。数据库系统权限(Database System Privilege)允许用户执行特定的命令集。例如,CREATE TABLE权限允许用户创建表,GRANT ANY P

6、RIVILEGE权限允许用户授予任何系统权限。数据库对象权限(Database Object Privilege)使得用户能够对各个对象进行某些操作。例如DELETE权限允许用户删除表或视图的行,SELECT权限允许用户通过select从表、视图、序列(sequences)或快照 (snapshots)中查询信息。4.1 创建用户Oracle内部有两个建好的用户:SYSTEM和SYS。用户可直接登录到SYSTEM用户以创建其他用户,由于SYSTEM具有创建别的用户的权限。在安装Oracle时,用户或系统管理员首先可以为自己建立一个用户。例如:create user user01 identif

7、ied by u01;该命令还可以用来设置其他权限。要转变一个口令,可以使用alter user命令:alter user user01 identified by usr01;现在user01的口令已由“u01”改为“usr01”。除了alter user命令以外,用户还可以使用password命令。假如使用password命令,用户输入的新口令将不在屏幕上显示。有dba特权的用户可以通过password命令转变任何其他用户的口令;其他用户只能转变自己的口令。当用户输入password命令时,系统将提示用户输入旧口令和新口令,如下所示:passwordChanging password fo

8、r user01Old password:New password:Retype new password:当成功地修改了口令时,用户会得到如下的反馈:Password changed4.2 删除用户删除用户,可以使用drop user命令,如下所示:drop user user01;假如用户拥有对象,则不能直接删除,否则将返回一个错误值。指定关键字CASCADE,可删除用户全部的对象,然后再删除用户。下面的例子用来删除用户与其对象:drop user user01 CASCADE;4.3 3种标准角色Oracle为了兼容以前的版本,供应了三种标准的角色(role):CONNECT、RESOU

9、RCE和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

10、。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角色的用户可以撤消任何别的用

11、户甚至别的DBA的CONNECT、RESOURCE 和DBA的其他权限。当然,这样是很危急的,因此,除非真正需要,DBA权限不应任凭授予那些不是很重要的一般用户。撤消一个用户的全部权限,并不意味着从Oracle中删除了这个用户,也不会破坏用户创建的任何表;只是简洁禁止其对这些表的访问。其他要访问这些表的用户可以象以前那样地访问这些表。五、创建角色除了前面讲到的三种系统角色-CONNECT、RESOURCE和DBA,用户还可以在Oracle创建自己的role。用户创建的role可以由表或系统权限或两者的组合构成。为了创建role,用户必需具有CREATE ROLE系统权限。5.1 创建rolec

12、reate 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连同与之相关的权限将从数据库中全部删除。六.

13、 oracle sys system 用户的区分sys是Oracle数据库中权限最高的帐号,具有create database的权限,而system没有这个权限,sys的角色是sysdba,system的角色是sysoper。其余就是他们两个用户共有的权限了:startup/shutdown/dba两个用户都是可以管理的。平常用system来管理数据库就可以了。这个用户的权限对于一般的数据库管理来说已经足够权限了。七. 查看权限和角色ORACLE中数据字典视图分为3大类, 用前缀区分,分别为:USER,ALL 和 DBA,很多数据字典视图包含相像的信息。USER_*: 有关用户所拥有的对象信息

14、,即用户自己创建的对象信息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用户可以

15、访问其他数据库用户对信息的用户名)另:select * from all_users;(全部数据库的用户信息,各用户的密码、状态、默认表空间、临时表空间等)7.2、查看scott用户自己拥有什么角色SQL> select * from user_role_privs;USERNAME GRANTED_ROLE ADM DEF OS_- - - - -SCOTT CONNECT NO YES NOSCOTT RESOURCE NO YES NO注:“ADM”表示这个用户是否可以把该具有的角色赐予给其他的用户另:没有all_role_privs这个视图另:select * from dba_

16、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 u

17、ser_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 NORESOURCE CREATE TRIGGER NORESOURCE CREATE CLUSTER NORESOURCE CREATE PROCEDURE

18、 NORESOURCE CREATE TYPE NORESOURCE CREATE OPERATOR NORESOURCE CREATE TABLE NORESOURCE 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_na

19、me,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_made7.10、把表的某一列操作权限赐予给其他用户SQL>grant update(job) on emp to mzl;注:查看数据库中全部的角色select * form. dba_rol

20、es;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 用户及作用介绍Oracle 官方文档对Oracle 的用户分成了三类:(1) PredefinedAdministrative Acc

21、ounts(2) PredefinedNon-Administrative User Accounts(3) PredefinedSample Schema User Accounts8.1 Predefined Administrative AccountsA default OracleDatabase installation provides a set of predefined administrative accounts. These are accounts that have specialprivileges required to administer areas of

22、 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 A

23、fter InstallationANONYMOUSAccount that allows HTTP access to Oracle XML DB. It is used in place of theAPEX_PUBLIC_USER account 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 cr

24、eate dynamic applications.Expired and lockedCTXSYSThe 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.See Oracle Text Applicati

25、on Developer's Guide.Expired and lockedDBSNMPThe account used by the Management Agent component of Oracle Enterprise Manager to monitor and manage the database.See Oracle Enterprise Manager Grid Control Installation and Basic Configuration.OpenPassword is created at installation or database crea

26、tion time.EXFSYSThe account used internally to access the EXFSYS schema, which is associated with the Rules Manager and Expression Filter feature. This feature enables you to build complex PL/SQL rules and expressions. The EXFSYS schema contains the Rules Manager and Expression Filter DDL, DML, and

27、associated metadata.See Oracle Database Rules Manager and Expression Filter Developer's Guide.Expired and lockedLBACSYSThe account used to administer Oracle Label Security (OLS). It is created only when you install the Label Security custom option.See "Enforcing Row-Level Security with Orac

28、le Label Security" and Oracle Label Security Administrator's Guide.Expired and lockedMDSYSThe Oracle Spatial and Oracle Multimedia Locator administrator account.See Oracle Spatial Developer's Guide.Expired and lockedMGMT_VIEWAn account used by Oracle Enterprise Manager Database Control.

29、OpenPassword 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 lockedOWBSYSThe account for administ

30、rating 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

31、.See Oracle Warehouse Builder Installation and Administration Guide.Expired and lockedORDPLUGINSThe 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 images, audio

32、, video, DICOM format medical images and other objects, or other heterogeneous media data integrated with other enterprise information.See Oracle Multimedia User's Guide and Oracle Multimedia Reference.Expired and lockedORDSYSThe Oracle Multimedia administrator account.See Oracle Multimedia User

33、's Guide, Oracle Multimedia Reference, and Oracle Multimedia DICOM Developer's Guide.Expired and lockedOUTLNThe account that supports plan stability. Plan stability prevents certain database environment changes from affecting the performance characteristics of applications by preserving exec

34、ution plans in stored outlines. OUTLN acts as a role to centrally manage metadata associated with stored outlines.See Oracle Database Performance Tuning Guide.Expired and lockedSI_INFORMTN_SCHEMAThe account that stores the information views for the SQL/MM Still Image Standard.See Oracle Multimedia U

35、ser's Guide and Oracle Multimedia Reference.Expired and lockedSYSAn account used to perform database administration tasks.See Oracle Database 2 Day DBA.OpenPassword is created at installation or database creation time.SYSMANThe account used to perform Oracle Enterprise Manager database administr

36、ation tasks. The SYS and SYSTEM accounts can also perform these tasks.See Oracle Enterprise Manager Grid Control Installation and Basic Configuration.OpenPassword is created at installation or database creation time.SYSTEMA default generic database administrator account for Oracle databases.For prod

37、uction systems, Oracle recommends creating individual database administrator accounts and not using the generic SYSTEM account for database administration operations.See Oracle Database 2 Day DBA.OpenPassword is created at installation or database creation time.TSMSYSAn account used for transparent

38、session migration (TSM).Expired and lockedWK_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 un

39、iform 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.See Oracle Ultra Search Administrator's Guide.Expired and lockedWKSYSAn Ultra Search dat

40、abase super-user. WKSYS can grant super-user privileges to other users, such as WK_TEST. All Oracle Ultra Search database objects are installed in the WKSYS schema.See Oracle Ultra Search Administrator's Guide.Expired and lockedWKPROXYAn administrative account of Oracle9i Application Server Ultr

41、a Search.See Oracle Ultra Search Administrator's Guide.Expired and lockedWMSYSThe account used to store the metadata information for Oracle Workspace Manager.See Oracle Database Workspace Manager Developer's Guide.Expired and lockedXDBThe account used for storing Oracle XML DB data and metad

42、ata.Oracle XML DB provides high-performance XML storage and retrieval for Oracle Database data.See Oracle XML DB Developer's Guide.Expired and locked8.2 PredefinedNon-Administrative User AccountsNon-administrativeuser accounts only have the minimum privileges needed to perform their jobs.Their d

43、efault 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 da

44、tabase access descriptor (DAD).Oracle Application Express is a rapid, Web application development tool for Oracle Database.See Oracle Database Application Express User's Guide.Expired and lockedDIPThe Oracle Directory Integration and Provisioning (DIP) account that is installed with Oracle Label

45、 Security. This profile is created automatically as part of the installation process for Oracle Internet Directory-enabled Oracle Label Security.See Oracle Label Security Administrator's Guide.Expired and lockedFLOWS_30000The account that owns most of the database objects created during the inst

46、allation of Oracle Database Application Express. These objects include tables, views, triggers, indexes, packages, and so on.See Oracle Database Application Express User's Guide.Expired and lockedFLOWS_FILESThe account that owns the database objects created during the installation of Oracle Data

47、base Application Express related to modplsql document conveyance, for example, file uploads and downloads. These objects include tables, views, triggers, indexes, packages, and so on.See Oracle Database Application Express User's Guide.Expired and lockedMDDATAThe schema used by Oracle Spatial fo

48、r 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.See Oracle Spatial Developer's Guide.Expired and lockedORACLE_OCMThe account used with Oracle Configur

49、ation 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

50、platform.Expired and lockedSPATIAL_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.See Oracle Spatial Develope

51、r's Guide.Expired and lockedSPATIAL_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.See Oracle Spatial Developer's Guide.Expired and l

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论