• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
火磷
Memory will fade,but not notes.
博客园    首页    新随笔    联系   管理    订阅  订阅
表空间

一.创建表空间

create tablespace test    //其中test为表空间名

datafile 'D:\study\test.dbf' size 10M     //指定路径和表空间大小

autoextend on next 5M     //允许自动扩展,每次扩展5M

extent management local uniform size 800K ||autoallocate

//决定表空间是数据字典管理方式还是本地化管理方式。可使用关键字uniform和autoallocate。

unifrom:后面可以添加规定每个区的大小的语句(size ??),若不添加,则默认每个区大小为1M

autoallocate:盘区大小自动分配,为默认选项

segment space management manual ||auto;  //表空间的管理方式,manual为手动,auto为自动方式。

2.管理表空间

1.为表空间增加新的数据文件,并且指定自动扩展属性

alter tablespace test     //选择表空间

add datafile 'D:\study\ts01.dbf' size 10M  //增加数据文件,其中数据文件ts01.dbf本不存在,是新创建的,大小必须指定。

autoextend on next 5M  //指定自动扩展属性

2.修改数据文件大小

select tablespace_name,file_id,bytes,blocks from dba_free_space;   //通过数据字典dba_free_space,了解表空间的分区情况

alter database datafile 'D:\study\ts01.dbf' resize 10M;     //修改大小

3.移动数据文件

alter tablespace test offline;  //将要修改的表空间设置为offline状态

alter tablespace test      //选择表空间

rename datafile 'D:\study\ts01.dbf' to 'E:\study\ts01.dbf';   //将数据文件移动另外的磁盘

4.删除表空间

drop tablespace test;   //删除表空间

drop tablespace test including contents and datafiles;    //删除表空间和其内的所有内容和数据文件

 

posted on 2015-06-25 20:11  火磷  阅读(217)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3