`

Oracle的表空间quota详解(原创)

 
阅读更多

表空间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

2
1
分享到:
评论

相关推荐

    ORACLE quota 表空间限制

    ORACLE quota 表空间限制,主要内容为测试ORACEL数据库对于表空间quota的限制

    oracle新手入门指导之六—ORACLE回收站详解.txt

    oracle新手入门指导之六—ORACLE回收站详解.txtoracle新手入门指导之六—ORACLE回收站详解.txt

    从一个表空间 另一个表空间

    我以前一直使用users表空间作为默认空间,最近想把现有用户的数据都转到一 个新建的表空间中,可是发现Imp后所有表还是在users表空间...还有指定user的表空间分配额度(quota),以及先导入然后更改表的表空间的 办法。

    Linux磁盘配额Quota配置详解.doc

    Linux磁盘配额Quota配置详解

    Oracle最常用的语句

     quota unlimited on 表空间名; --在表空间下面建表不受限制 4.创建角色  create role 角色名 identified by 密码; 5.给角色授权  grant create session to 角色名;--给角色授予创建会话的权限  grant 角色名 ...

    Oracle常用的命令如何查看表的结构

    12 quota unlimited on 表空间名; --在表空间下面建表不受限制 4.创建角色 create role 角色名 identified by 密码; 5.给角色授权 grant create session to 角色名;--给角色授予创建会话的权限 grant 角色名 to ...

    Linux quota命令用法详解

    Linux quota命令用于显示磁盘已使用的空间与限制。 执行quota指令,可查询磁盘空间的限制,并得知已使用多少空间。 语法quota [-quvV][用户名称...] 或 quota [-gqvV][群组名称...] 参数说明: -g 列出群组的磁盘...

    exp转换表空间

    将设置目标用户的默认表空间为导入的目的表空间,在默认表空间上授予QUOTA UNLLIMITED,回收改用户的UNLIMITED TABLESPACE权限: 看一个简单的例子: SQL> CREATE TABLESPACE TESTEXP DATAFILE '/data/oradata/...

    Linux quota ppt课件

    Linux quota ppt课件Linux quota ppt课件

    oracle从入门到精通.pdf

    1、用户 2、方案或模式(Schema):是用户所对应...用户可以在表空间上可以使用的空间。 端口:2030 环境变量 -ORACLE_BASE 基本目录 -ORACLE_NAME 当前的主目录 -ORACLE_NLS33 使用 US7ASCLL 字符集时不用设 -PATH 路径

    Oracle 主要配置文件介绍

    Oracle 应 用进行文件 I/O操作的目录为任意目录 因此 只要空间允许 可以将备份数 据存放到任意目录下 <br>1.2.4 监听配置文件 为了使得外部进程 如 CAMS后台程序 能够访问 Oracle 数据库 必须配 ...

    quota-4.00

    linux quota

    proftpd + mysql + quota配置完全指南

    proftpd + mysql + quota配置完全指南proftpd + mysql + quota配置完全指南proftpd + mysql + quota配置完全指南proftpd + mysql + quota配置完全指南

    最全的oracle常用命令大全.txt

    2、查看表空间物理文件的名称及大小 select tablespace_name, file_id, file_name, round(bytes/(1024*1024),0) total_space from dba_data_files order by tablespace_name; 3、查看回滚段名称及大小 ...

    【持续更新】Oracle 常用的系统命令

    一、基础环境   操作系统:Windows 或 Linux ...[QUOTA 表空间配额数值[K|M]|UNLIMITED ON默认表空间名称] --如果该选项省略,则用户在表空间上的配额为0,不能在表空间上建立数据库对象。 [TEMPORARY TABLESP

    quota命令 显示磁盘已使用的空间与限制

    quota命令用于显示磁盘已使用的空间与限制。执行quota命令可查询磁盘空间的限制,并得知已使用多少空间。 语法参数:quota [参数] 常用参数: -g 列出群组的磁盘空间限制 -q 简明列表,只列出超过限制的...

    proftpd支持mysql和quota配额

    proftpd支持mysql和quota配额

    linux下vsftp的搭建及quota的使用

    linux下vsftp的搭建及quota的使用

    netapp存储配置练习_quota

    实用资源,netapp存储配置练习_quota

    quota磁盘配额操作手册

    在linux系统中,由于是多人多工的环境,所以会有多人共同使用一个硬盘空间的情况,如果其中有少数几个使用者大量占掉了硬盘空间,势必会压缩其他人的使用权利。

Global site tag (gtag.js) - Google Analytics