Oracle的表空间quota详解[通俗易懂]

转载至:http://czmmiao.iteye.com/blog/1291984表空间quota概述Oracle官网对quota的定义如下:Alimitonaresource,suchasalimitontheamountofdatabasestorageusedbyadatabaseuser.Adatabaseadministra

大家好,又见面了,我是你们的朋友全栈君。

转载至:http://czmmiao.iteye.com/blog/1291984

表空间quota概述

Oracle 官网对quota的定义如下: A limit on a resource, such as a limit on the amount of database storage used by a database user. A database administrator can set tablespace quotas for each Oracle Database username
有关Oracle Quota 这块可以参考Oracle官方文档
http://download.oracle.com/docs/cd/E11882_01/network.112/e16543

quota的日常管理

常见问题

ORA-01536:space   quota   exceeded   for   table   space   ‘CYYD’ 
解决办法:
 
alter   user   USERNAME   quota   100M   on   TABLESPACENAME;  
alter   user   USERNAME   quota   unlimited   on   TABLESPACENAME; 
grant   unlimited   tablespace   to   USERNAME;
 
quota是为了限制用户对表空间的使用,比如你限制用户Guotu在tablespace  CYYD中的quota为10m,当用户Guotu在tablespace   CYYD中的数据量达到10m后,无论你的tablespace   CYYD中有多少空间,Guotu都无法再使用tablespace   CYYD了。
所以你需要: 

alter   user   aGuotu  quota   1000M   on   CYYD; 
alter   user   Guotu   quota   unlimited   on   CYYD; 
grant   unlimited   tablespace   to   Guotu

dba_ts_quotas

与quota相关的数据字典视图为dba_ts_quotas,以下是相关的信息
Assigning a Tablespace Quota for the User
You can assign each user a tablespace quota for any tablespace (except a temporary tablespace). Assigning a quota accomplishes the following:
Users with privileges to create certain types of objects can create those objects in the specified tablespace.
Oracle Database limits the amount of space that can be allocated for storage of a user’s objects within the specified tablespace to the amount of the quota.
By default, a user has no quota on any tablespace in the database. If the user has the privilege to create a schema object, then you must assign a quota to allow the user to create objects. At a minimum, assign users a quota for the default tablespace, and additional quotas for other tablespaces in which they can create objects.

可以使用下列语句来创建用户
CREATE USER jward
 IDENTIFIED BY password
 DEFAULT TABLESPACE data_ts
 QUOTA 100M ON test_ts
 QUOTA 500K ON data_ts
 TEMPORARY TABLESPACE temp_ts
 PROFILE clerk;

配额的指定可以禁止用户的对象使用过多的表空间

You can assign a user either individual quotas for a specific amount of disk space in each tablespace or an unlimited amount of disk space in all tablespaces. Specific quotas prevent a user’s objects from using too much space in the database.
You can assign quotas to a user tablespace when you create the user, or add or change quotas later. (You can find existing user quotas by querying the USER_TS_QUOTAS view.) 。
 If a new quota is less than the old one, then the following conditions remain true:
(1)If a user has already exceeded a new tablespace quota, then the objects of a user in the tablespace cannot be allocated more space until the combined space of these objects is less than the new quota.
(2)If a user has not exceeded a new tablespace quota, or if the space used by the objects of the user in the tablespace falls under a new tablespace quota, then the user’s objects can be allocated space up to the new quota.
Restricting the Quota Limits for User Objects in a Tablespace 
You can restrict the quota limits for user objects in a tablespace by using the ALTER USER SQL statement to change the current quota of the user to zero.
 After a quota of zero is assigned, the objects of the user in the tablespace remain, and the user can still create new objects, but the existing objects will not be allocated any new space.
For example, you could not insert data into one of this user’s exiting tables. The operation will fail with an ORA-1536 space quota exceeded for tables error.
Granting Users the UNLIMITED TABLESPACE System Privilege 
To permit a user to use an unlimited amount of any tablespace in the database, grant the user the UNLIMITED TABLESPACE system privilege. This overrides all explicit tablespace quotas for the user. If you later revoke the privilege, then you must explicitly grant quotas to individual tablespaces. You can grant this privilege only to users, not to roles.
Before granting the UNLIMITED TABLESPACE system privilege, you must consider the consequences of doing so.
Advantage:
You can grant a user unlimited access to all tablespaces of a database with one statement.
Disadvantages:
(1)The privilege overrides all explicit tablespace quotas for the user.
(2)You cannot selectively revoke tablespace access from a user with the UNLIMITED TABLESPACE privilege. You can grant selective or restricted access only after revoking the privilege.
Listing All Tablespace Quotas
Use the DBA_TS_QUOTAS view to list all tablespace quotas specifically assigned to each user. For example:
 
SELECT * FROM DBA_TS_QUOTAS;
 TABLESPACE    USERNAME    BYTES     MAX_BYTES    BLOCKS    MAX_BLOCKS
———-    ———  ——–   ———-   ——-   ———-
USERS         JFEE              0       512000         0          250
USERS         DCRANNEY          0           -1         0           -1
 
When specific quotas are assigned, the exact number is indicated in the MAX_BYTES column . This number is always a multiple of the database block size, so if you specify a tablespace quota that is not a multiple of the database block size, then it is rounded up accordingly. Unlimited quotas are indicated by -1. 
注意当对用户赋予resource角色时将同时赋予unlimited tablespace的系统权限。详情见下文

创建用户 

SQL> create user test_privs identified by test_privs default tablespace users;
User created.

SQL> select * from dba_sys_privs where GRANTEE=’TEST_PRIVS’;
no rows selected 
赋予resource角色 
SQL> grant resource to TEST_PRIVS;
Grant succeeded.
 

查询resource角色所具有的系统权限

SQL> select * from dba_sys_privs where GRANTEE=’RESOURCE’;

GRANTEE                        PRIVILEGE                                ADM
—————————— —————————————- —
RESOURCE                       CREATE TRIGGER                           NO
RESOURCE                       CREATE SEQUENCE                          NO
RESOURCE                       CREATE TYPE                              NO
RESOURCE                       CREATE PROCEDURE                         NO
RESOURCE                       CREATE CLUSTER                           NO
RESOURCE                       CREATE OPERATOR                          NO
RESOURCE                       CREATE INDEXTYPE                         NO
RESOURCE                       CREATE TABLE                             NO
查看用户所具有的角色 
SQL> select * from dba_role_privs where GRANTEE=’TEST_PRIVS’;
GRANTEE                        GRANTED_ROLE                   ADM DEF
—————————— —————————— — —
TEST_PRIVS                     RESOURCE                       NO  YES
查询用户所具有的系统权限 

SQL> select * from dba_sys_privs where GRANTEE=’TEST_PRIVS’;
GRANTEE                        PRIVILEGE                                ADM
—————————— —————————————- —
TEST_PRIVS                     UNLIMITED TABLESPACE                     NO
 
可以看到,Oracle默认的把unlimited tablespace的系统权限赋予了用户

查询表空间

SQL> select TABLESPACE_NAME,USERNAME,BYTES,MAX_BYTES from dba_ts_quotas;

TABLESPACE_NAME                USERNAME        BYTES  MAX_BYTES
—————————— ———- ———- ———-
INDX                           HR              65536   10485760
SYSAUX                         OLAPSYS      16318464         -1
USERS                          HR             196608         -1
SYSAUX                         SYSMAN       54460416         -1
SYSAUX                         DMSYS          262144  209715200
TRANS                          TRANS               0   10485760
可以看到对于具有unlimited tablespace系统权限的用户,在dba_ts_quota上没有体现。

这里补充说一句,一般创建用户时,如果没有特殊需求只要将resource和connect角色赋予用户即可。
SQL> select * from dba_sys_privs where GRANTEE= ‘CONNECT’;
ROLE                           PRIVILEGE                                ADM
—————————— —————————————- —
CONNECT                        CREATE SESSION                           NO
 

SQL> grant resource,connect to test_privs;
Grant succeeded.
 

参考至:http://docs.oracle.com/cd/E11882_01/network.112/e16543/users.htm#DBSEG10220

           http://tech.it168.com/o/2006-04-08/200604081532523.shtml
           http://www.itpub.net/thread-345851-1-1.html

本文原创,转载请注明出处、作者

如有错误,欢迎指正

邮箱:czmcj@163.com

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/126253.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • Linux时间戳转换_如何获取时间戳

    Linux时间戳转换_如何获取时间戳#include<stdio.h>#include<time.h>intmain(){time_tt;//时间戳structtm*p;time(&t);//获取时间戳p=localtime(&t);//将时间戳转换为本地时间printf(“时间戳:%ld\n”,t);printf(“%d-%d-%d%d:%d:%d\n”,(1900+

  • 数据库课程设计(饭店点餐系统)

    数据库课程设计(饭店点餐系统)1.需求分析2.概念结构设计2.1数据需求2.1.1下订单阶段需要的数据:2.1.2点菜阶段需要的数据:2.1.3结账阶段需要的数据:2.1.4员工管理需要的数据:2.1.5顾客管理需要的数据:2.1.6消费记录管理需要的数据有:2.2事务需求2.2.1数据录入2.2.2数据更新/删除2.2.3数据查询2.3数据项2.2抽象出系统的实体2.3设计E-R图2.3.1菜谱(Menus)E-R图2.3.2顾客(Tomer)E…

  • ArcGIS二次开发基础教程(10):三维分析

    ArcGIS二次开发基础教程(10):三维分析ArcGIS二次开发基础教程(10):三维分析坡度分析请务必学会使用帮助文档!!!//DEM数据的坡度分析将分析结果添加到地图上//首先获取DEM数据,方法有很多例如从个人地理数据库获取,也可直接获取文件数据,此处采用第二种方法IWorkspaceFactoryworkspaceFactory=newShapefileWorkspaceFactoryClass();//从文件…

  • Lucene 3.0.0 的TokenStream与Analyzer

    Lucene 3.0.0 的TokenStream与Analyzer如果你看的Lucene相关的书是很老版本的,比如说2.4或者更早,那么对于这个版本中的Analyzer可能就不那么容易接受了,我也是看的<lucene分析与应用>这本书,比较古老的版本.今天读了一下源代码,大概说说心得,我从SimpleAnalyzer说起.SimpleAnalyzer的作用就是把一段字符串中除了符号和非文字的内容作为分…

  • native2ascii命令_native method

    native2ascii命令_native methodnative2ascii是一个关于转码的不错的命令.使用条件简单,只要安装了jdk之后,在cmd窗口就可以使用该命令对文件进行转码,而且转码过程是可逆的.安装路径下bin目录下,有一个native2ascii 批处理文件也可以完成转码.具体的语法如下:native2ascii-[options][inputfile[outputfile]]-[options]:表示命令开关,

  • luajit缺点_luajit和lua区别

    luajit缺点_luajit和lua区别作者:paintsnow链接:https://www.zhihu.com/question/49144449/answer/123116906来源:知乎著作权归作者所有,转载请联系作者获得授权。其实我是不主张在开发时就用LuaJIT的,因为这样会把人养懒……因为JIT的强大性能,掩盖了太多代码中的低效实现,反而最后想要提升性能已经不可能了==回到正题,我的建议是,如果

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号