---------------------------------------------- -表空间的操作----------------------------------------------------

1.创建表空间:

create tablespace tablespace_name datafile 'filepath' size filesize autoextend on next autosize maxsize filemaxsize [unlimited]

eg:

create tablespace sales datafile 'c:\1.txt' size 10m autoextend on next 1m maxsize 100m

2.为表空间增加数据文件:

alter tablespace tablespace_name add datafile 'filepath' size filesize autoextend on next autosize maxsize filemaxsize[unlimited]

eg:

alter tablespace sales datafile 'c:\2.txt' size 10m autoextend on next 1m maxsize unlimited

3.调整表空间:

alter database datafile 'filepath' resize filesize--重置表空间的大小

eg:

alter database datafile 'c:\2.txt' resize 10m

4.关闭表空间的自动扩展属性:

alter database datafile 'filepath' autoextend off

eg:

alter database datafile 'c:\2.txt' autoextend off

5.打开表空间的自动扩展属性:

alter database datafile 'filepath' autoextend on

eg:

alter database datafile 'c:\2.txt' autoextend on

6.使表空间脱机:

alter tablespace tablespace_name offline

7.使表空间联机:

alter tablespace tablespace_name online

8.设置表空间为只读:

alter tablespace tablespace_name read only

9.设置表空间为读写:

alter tablespace tablespace_name read write

11.删除表空间:

drop tablespace tablespace_name

12.删除表空间的同时,删除数据文件

drop tablespace tablespace_name including contents and datefiles

13.查看每个表空间占用空间的大小:

select tablespace_name,sum(bytes)/1024/1024 from dba_segments group by tablespace_name

10.移动表空间数据文件步骤:

a.使表空间脱机:alter tablespace tablespace_name offline

b.物理移动数据文件到目的地(可以是表空间的部分数据文件或者是修改数据文件的名称)

c.逻辑移动:alter tablespace tablespace_name rename datafile '源文件地址'to '目的文件地址'--注意可以将多个源文件转移到同一个目的文件地址(多个源文件地址用逗号分隔)

d.将表空间联机:alter tablespace tablespace_name online

11.查询表空间的信息:

select tablespace_name,bytes/1024/1024  file_size_mb,file_name from DBA_DATE_FILES--注意书籍库中的实体都是以大写表示

12.当数据文件被删除的时候,如果对该数据文件操作的时候,oracle会报不能找到该数据文件的错误。如何处理。

1shutdown—关闭oracle实例

2startup  --开启oracle实例并打开数据库

3alter database datafile ‘datafile_name’ offline drop;

4alter database open

------------------------------------------------------------------------------------------------------------------

评论
发表评论

您还没有登录,请登录后发表评论

linsl
搜索本博客
我的相册
6e6fdb31-fc9a-3aa1-9a18-fb2dbeec32fc-thumb
jbpm
共 1 张
最近加入圈子
存档
最新评论