oracle表空间Managing Tablespace & Data Files(二)

2014-11-24 17:06:29 · 作者: · 浏览: 1
dentified by fc default tablespace shanxi
③、赋予权限
grant connect,resource to fc;
④、登录
conn fc/fc@oamis;
⑤、创建表并添加记录 提交
create table t (id integer,name char(10));
insert into t values(1,'yuncheng');
commit;
⑥、修改表空间只读
alter tablespace shanxi read only;
⑦、测试结果
不能增删改 只能drop
⑧、恢复表空间write
alter table shanxi read write;
十一、Taking a Tablespace Offline(使表空间离线)
表空间状态(read ,write,offline ,online)
1、Not avaliable for data access
2、Tablespace that cannot be taken offline
①、system tablespace www.2cto.com
②、Tablespaces whit active undo segment ()
③、Default temporary tablespace (temporary tablespace 不是默认的可以离线)
2、测试表空间离线
①、创建表 添加数据
create table t2 (id integer,name char(10));
insert into t2 values(1,'aaa');
insert into t2 values(2,'bbb');
commit;
insert into t2 values(3,'ccc');
②、将表空间shanxi离线(sys用户)
alter tablespace shanxi offline;(表空间离线)
这个时候查询不行了
alter tablespace shanxi online; (表空间在线)
这个时候可以了
十二、Changing Storage Settingg(改变存储设置)
1、可以分为三个层次进行设置(数据库级,表空间级,segament级)
2、Storage setting for locally managed tablespaces cannot be altered;
十三、Resizing a TableSpace(调整表空间的大小)
A tablespace can be resized by:
1、Changing the size of a data file(改变数据文件的大小)
①、Automatically using autoextend (自动改变,一个步调,一个极限)
三种方式实现: create database ,create tablespace,alter tablespace ...add datafile
Example:
Create Tablespace user_data
datafile='/u01/oradata/userdata01.dbf' size=200M
autoextend on next 10m maxsize 500M; (可以应用于create database 或者 create tablespace) www.2cto.com
修改表空间(增加一个)
alter tablespace shanxi add datafile
'/u01/app/oracle/product/10.2.0/oradata/oamis/shanxi2.dbf' size 20m
autoextend on next 10M maxsize 100M;
修改表空间(修改原来的)
alter database datafile '/u01/app/oracle/product/10.2.0/oradata/oamis/shanxi.dbf'
autoextend on next 10m maxsize 100M;
查询tablespace是否自动增长
select file_name,tablespace_name,autoextensible from dba_data_files;
②、Manually using Alter Database (手工改变方式)
(从小的往大变,如果从大的往小变则根据数据库文件实际的大小来定)
Alter database datafile '/u01/app/oracle/product/10.2.0/oradata/oamis/shanxi.dbf' resize 20M;
2、Add a data file using Alter Tablespace (添加一个新的)
(这种方式好,例如一个100G跟10个10g,10个的这个会并发,速度快)
alter tablespace shanxi add datafile '/u01/app/oracle/product/10.2.0/oradata/oamis/shanxi3.dbf' size 5M;
3、查询表空间的使用情况(这个查询需要点时间)
主要是 DBA_DATA_FILES和dba_free_space
select f.tablespace_name,a.total,u.used,f.free,round((u.used/a.total)*100) "% used", round((f.free/a.total)*100) "% Free"
from
(select tablespace_name, sum(bytes/(1024*1024)) total
from dba_data_files group by tablespace_name) a,
(select tablespace_name, round(sum(bytes/(1024*1024))) used
from dba_extents group by tablespace_name) u,
(select tablespace_name, round(sum(bytes/(1024*1024))) free
from dba_free_space group by tablespace_name) f
WHERE a.tablespace_name = f.tablespace_name and a.tablespace_name = u.tablespace_name;
www.2cto.com
临时表空间在DBA_TEMP_FILES中查找
十四、Methods for movi