oracle数据文件和表空间

1、先查询空闲空间
select tablespace_name,file_id,block_id,bytes,blocks from dba_free_space;

2、增加表空间
先查询数据文件名称、大小和路径的信息,语句如下:
select tablespace_name,file_id,bytes,file_name from dba_data_files;

 

修改文件大小语句如下
alter database datafile '需要增加的数据文件路径,即上面查询出来的路径' resize 800M;

4、创建表空间
create tablespace test
datafile '/home/app/oracle/oradata/oracle8i/test01.dbf' size 8M
autoextend on
next 5M
maxsize 10M;

create tablespace sales
datafile '/home/app/oracle/oradata/oracle8i/sales01.dbf' size 800M
autoextend on
next 50M
maxsize unlimited
maxsize unlimited 是大小不受限制

create tablespace sales
datafile '/home/app/oracle/oradata/oracle8i/sales01.dbf' size 800M
autoextend on
next 50M
maxsize 1000M
extent management local uniform;
unform表示区的大小相同,默认为1M

create tablespace sales
datafile '/home/app/oracle/oradata/oracle8i/sales01.dbf' size 800M
autoextend on
next 50M
maxsize 1000M
extent management local uniform size 500K;
unform size 500K表示区的大小相同,为500K

create tablespace sales
datafile '/home/app/oracle/oradata/oracle8i/sales01.dbf' size 800M
autoextend on
next 50M
maxsize 1000M
extent management local autoallocate;
autoallocate表示区的大小由随表的大小自动动态改变,大表使用大区小表使用小区

create tablespace sales
datafile '/home/app/oracle/oradata/oracle8i/sales01.dbf' size 800M
autoextend on
next 50M
maxsize 1000M
temporary;
temporary创建字典管理临时表空间

create temporary tablespace sales
tempfile '/home/app/oracle/oradata/oracle8i/sales01.dbf' size 800M
autoextend on
next 50M
maxsize 1000M
创建本地管理临时表空间,如果是临时表空间,所有语句中的datafile都换为tempfile

8i系统默认创建字典管理临时表空间,要创建本地管理临时表空间要加temporary tablespace关键字
创建本地管理临时表空间时,不得使用atuoallocate参数,系统默认创建uniform管理方式

为表空间增加数据文件:
alter tablespace sales add
datafile '/home/app/oracle/oradata/oracle8i/sales02.dbf' size 800M
autoextend on next 50M
maxsize 1000M;


5、更改自动扩展属性:
alter database datafile
'/home/app/oracle/oradata/oracle8i/sales01.dbf',
'/home/app/oracle/oradata/oracle8i/sales02.dbf'
'/home/app/oracle/oradata/oracle8i/sales01.dbf
autoextend off;

6、查询表空间状态
select tablespace_name,status from dba_tablespaces;

7、更改表空间的状态
alter tablespace book offline/online/read only/read write;
离线/在线/只读/读写

8、数据文件移动
select tablespace_name,file_name from dba_data_files;
alter tablespace book offline;
将要修改的文件移动到新目录下
alter tablespace book rename datafile '/u01/oradata/oracle8i/sales01.dbf' to '/u02/oradata/oracle8i/sales01.dbf';

9、修改数据文件的online/offline属性
archivelog模式下
alter database datafile '/u01/oradata/oracle8i/sales01.dbf' offline;

noarchivelog模式下
alter database datafile '/u01/oradata/oracle8i/sales01.dbf' offline drop;

 

10、数据字典表空间与本地化管理表空间的转化为
select tablespace_name,extent_management,allocation_type from dba_tablespace;
exec dbms_space_admin.tablespace_migrate_to_local('book') 字典转本地
系统表空间system和临时表空间temp不得转换

exec dbms_space_admin.tablespace_migrate_from_local('book') 本地转字典


11、删除表空间
drop tablespace student including contents;
including contents将表空间及实体删除

create table test(id number(3)) tablespace test_tablesapce;
 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值