Oracle operate tablespace
2013-11-19 10:35
155 查看
*创建临时表空间
create temporary tablespace test_temp tempfile 'E:\oracle\product\10.1.0\oradata\orcl\test_temp01.dbf' size 32m autoextend on next 32m maxsize 2048m extent management local;*创建用户表间
create tablespace test_data logging datafile 'E:\oracle\product\10.1.0\oradata\orcl\test_temp01.dbf' size 32m autoextend on next 32m maxsize 2048m extent management local;*重设表间大小 有两种方法,一种是为表空间增加数据文件
alter tablespace tablespace_name add datafile 'filepath' size filesize autoextend on next autosize maxsize filemaxsize
alter tablespace users add datafile 'E:\oracle\ora81\oradata\sid\user002.dbf' size 100M;另一种方法是增加表空间原有数据文件尺寸:
alter database datafile 'filepath' resize filesize
alter database datafile 'c:\oracle\ora81\oradata\\sid\users.dbf' resize 1000M;alter database datafile 'c:\oracle\ora81\oradata\\sid\users.dbf' resize 1000M; *关闭表空间的自动扩展属性
alter database datafile 'filepath' autoextend off*打开表空间的自动扩展属性
alter database datafile 'filepath' autoextend on*使表空间脱机
alter tablespace tablespace_name offline*使表空间联机
alter tablespace tablespace_name online*设置表空间为只读
alter tablespace tablespace_name read only*设置表空间为读写
alter tablespace tablespace_name read write*删除表空间
drop tablespace tablespace_name*删除表空间的同时,删除数据文件
drop tablespace tablespace_name including contents and datefiles*移动表空间数据文件步骤
a.使表空间脱机: alter tablespace tablespace_name offline b.物理移动数据文件到目的地(可以是表空间的部分数据文件或者是修改数据文件的名称) c.逻辑移动:alter tablespace tablespace_name rename datafile '源文件地址'to '目的文件地址'--注意可以将多个源文件转移到同一个目的文件地址(多个源文件地址用逗号分隔) d.将表空间联机:alter tablespace tablespace_name online*查看表空间使用状况
select a.a1 表空间名称,c.c2 类型,c.c3 区管理,b.b2/1024/1024 表空间大小M,(b.b2-a.a2)/1024/1024 已使用M,substr((b.b2-a.a2)/b.b2*100,1,5) 利用率 from (select tablespace_name a1, sum(nvl(bytes,0)) a2 from dba_free_space group by tablespace_name) a, (select tablespace_name b1,sum(bytes) b2 from dba_data_files group by tablespace_name) b, (select tablespace_name c1,contents c2,extent_management c3 from dba_tablespaces) c where a.a1=b.b1 and c.c1=b.b1;*查看表空间对应的文件
select * from dba_data_filesOracle 默认的表空间大小为400M,当数据库中数据量达到这个值,再向数据库中导入数据就会报错。解决方法是扩展表空间。可以选择将表容量扩大,比如扩展到5G,或者当表空间不够时每次自动增加一定的容量,如每次自增200M。下面列出详细过程:1.通过sql plus 命令登录数据库。 在命令行下输入sqlplus “登录用户名/口令 as 登录类型”就可以登录,系统内建的用户名常用的是sys,密码是在安装oracle过程中设置的密码,清务必牢记,如果用sys帐户登录,登录类型一定要是sysdba。2.查看各表空间分配情况。select tablespace_name, sum(bytes) / 1024 / 1024 from dba_data_files group by tablespace_name; 3.查看各表空间空闲情况。select tablespace_name, sum(bytes) / 1024 / 1024 from dba_free_space group by tablespace_name; 4.更改数据表大小(10G)alter database datafile '/ora/oradata/radius/undo.dbf' resize 10240m;5.设置表空间不足时自动增长5.1查看表空间是否自动增长SELECT FILE_NAME,TABLESPACE_NAME,AUTOEXTENSIBLE FROM dba_data_files;5.2 设置表空间自动增长ALTER DATABASE DATAFILE 'c:\SmartDB01.ora' AUTOEXTEND ON;//打开自动增长ALTER DATABASE DATAFILE 'c:\SmartDB01.ora' AUTOEXTEND ON NEXT 200M ;//每次自动增长200mALTER DATABASE DATAFILE 'c:\SmartDB01.ora' AUTOEXTEND ON NEXT 200M MAXSIZE 1024M;//每次自动增长200m,数据表最大不超过1G
相关文章推荐
- Oracle的resouce、unlimited tablespace 及如何把数据导入不同的表空间
- Oracle 默认表空间(default permanent tablespace) 说明
- 聊聊Oracle可传输表空间(Transportable Tablespace)
- Oracle Temporary tablespace group
- 详解Oracle的unlimited tablespace系统权限
- Oracle TTS ORA-39322: Cannot use transportable tablespace with different timezone version 说明
- 使用rman在不同平台之间传送oracle asm表空间(transport tablespace)
- Oracle Tablespace & Datafiles--Oracle表空间--应用实例(2)
- oracle tablespace datafile入门1
- Oracle 默认表空间(default permanent tablespace) 说明
- Oracle Tablespace
- Oracle tablespace usage rate
- Oracle - ORA-30036: unable to extend segment by 8 in undo tablespace 'UNDOTBS1'
- Oracle Tablespace Map 功能 说明
- Oracle Block Extent Segment Tablespace
- Oracle的unlimited tablespace系统权限
- Oracle TTS ORA-39322: Cannot use transportable tablespace with different timezone version 说明
- Oracle Tablespace & Datafiles--Oracle表空间--应用实例(1)
- oracle datafile and tablespace
- Oracle RMAN Transport Tablespace - 兼容性检查