1。查看数据文件存放的路径
22:35:59 sys@orclzad> select name from v$datafile;
NAME
/paic/app/dbshare/oracle/zhenganding/oradata/orclzad/system01.dbf
/paic/app/dbshare/oracle/zhenganding/oradata/orclzad/sysaux01.dbf
/paic/app/dbshare/oracle/zhenganding/oradata/orclzad/undotbs01.dbf
/paic/app/dbshare/oracle/zhenganding/oradata/orclzad/users01.dbf
/paic/app/dbshare/oracle/zhenganding/oradata/orclzad/example01.dbf
/paic/app/dbshare/oracle/zhenganding/11.2.0.4.5/tt.dbf
6 rows selected
2。创建一个表空间,并指定一个数据文件(使用上一步查询出来的路径)
22:36:16 sys@orclzad> create tablespace tbspce datafile ‘/paic/app/dbshare/oracle/zhenganding/oradata/orclzad/tbspce01.dbf’ size 50M;
Tablespace created
3。查看是否直接分配了50M空间:
[zhenganding@cnsh230235 ~]$ ls -lh /paic/app/dbshare/oracle/zhenganding/oradata/orclzad/tbspce01.dbf
-rw-r—– 1 zhenganding oinstall 51M Aug 3 22:52 /paic/app/dbshare/oracle/zhenganding/oradata/orclzad/tbspce01.dbf
可以看到,已经预分配好了相关的空间
4。添加新的数据文件
22:53:35 sys@orclzad> alter tablespace tbspce add datafile ‘/paic/app/dbshare/oracle/zhenganding/oradata/orclzad/tbspce02.dbf’ size 50M;
Tablespace altered
5。查看数据文件编号和相关的路径名称:
22:59:10 sys@orclzad> select file#, name from v$datafile;
FILE# NAME
1 /paic/app/dbshare/oracle/zhenganding/oradata/orclzad/system01.dbf
2 /paic/app/dbshare/oracle/zhenganding/oradata/orclzad/sysaux01.dbf
3 /paic/app/dbshare/oracle/zhenganding/oradata/orclzad/undotbs01.dbf
4 /paic/app/dbshare/oracle/zhenganding/oradata/orclzad/users01.dbf
5 /paic/app/dbshare/oracle/zhenganding/oradata/orclzad/example01.dbf
6 /paic/app/dbshare/oracle/zhenganding/11.2.0.4.5/tt.dbf
7 /paic/app/dbshare/oracle/zhenganding/oradata/orclzad/tbspce01.dbf
8 /paic/app/dbshare/oracle/zhenganding/oradata/orclzad/tbspce02.dbf
8 rows selected
6。由于我们没有在表空间创建对象,所以,我们是可以回收数据文件上的空间的:
23:05:05 sys@orclzad> select sum(bytes) from dba_segments s where s.tablespace_name=’TBSPCE’;
SUM(BYTES)
7。尝试回收,两个数据文件的空间:
23:05:14 sys@orclzad> alter database datafile 7 resize 40M;
Database altered
23:10:28 sys@orclzad> alter database datafile 8 resize 40M;
Database altered
这里没有对已经有数据的表空间,进行空间的resize,我们将会对这部分内容进行研究。