码迷,mamicode.com
首页 > 数据库 > 详细

Oracle表空间管理

时间:2016-01-29 11:44:16      阅读:240      评论:0      收藏:0      [点我收藏+]

标签:

1.创建表空间

create tablespace yyy
datafile /u01/oracle/oradata/orcl/yyy01.dbf
size 50m
autoextend on
next 50m maxsize unlimited
extent management local

2. 创建用户

create user yyy identified by yyy
default tablespace yyy
temporary tablespace temp
profile DEFAULT

3.用户授权

-- Grant/Revoke object privileges
grant select on SYS.V_$SESSION to yyy;
grant select on SYS.V_$SESSTAT to yyy;
grant select on SYS.V_$STATNAME to yyy;
-- Grant/Revoke role privileges
grant connect to yyy;
grant resource to yyy;
-- Grant/Revoke system privileges
grant create view to yyy;
grant debug connect session to yyy;
grant unlimited tablespace to yyy;

4.查询表空间的大小

SELECT t.tablespace_name, round(SUM(bytes / (1024 * 1024)), 0) ts_size
FROM dba_tablespaces t, dba_data_files d
WHERE t.tablespace_name = d.tablespace_name
GROUP BY t.tablespace_name;

5.查看表空间对应的数据文件id和数据文件名称

SELECT tablespace_name,
file_id,
file_name,
round(bytes / (1024 * 1024), 0) total_space
FROM dba_data_files
ORDER BY tablespace_name;

6.查看表空间的使用情况

SELECT a.tablespace_name,
a.bytes/1024/1024 "total/m",
b.bytes/1024/1024 "used/m",
c.bytes/1024/1024 "free/m",
Round((c.bytes * 100)/a.bytes,2) " FREE %"
FROM sys.sm$ts_avail a, sys.sm$ts_used b, sys.sm$ts_free c
WHERE a.tablespace_name = b.tablespace_name
AND a.tablespace_name = c.tablespace_name;

7.更改表空间大小(dbf)

alter database datafile 数据文件路径 resize 大小;

8.删除表空间及关联关系

DROP TABLESPACE tablesapce_name including contents and datafiles cascade constraint;

 

Oracle表空间管理

标签:

原文地址:http://www.cnblogs.com/cancer-sun/p/5168235.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!