Oracle表空间使用情况查看

--查看数据文件

SQL> select file_name from dba_data_files;

FILE_NAME

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

/oradata/lianxi/users01.dbf

/oradata/lianxi/sysaux01.dbf

/oradata/lianxi/undotbs01.dbf

/oradata/lianxi/system01.dbf

--查看临时数据文件,发现没有,是因为之前做过重建控制文件导致的,需要重新加载临时文件

SQL> select file_name from dba_temp_files;

no rows selected

--给临时表空间加临时数据文件

SQL> alter tablespace temp add tempfile '/oradata/lianxi/temp01.dbf';

Tablespace altered.

--查看临时数据文件

SQL> select file_name from dba_temp_files;

FILE_NAME

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

/oradata/lianxi/temp01.dbf

--查看数据文件大小

SQL> select tablespace_name,sum(bytes)/1024/1024 "size(M)" from dba_data_files group by tablespace_name;

TABLESPACE_NAME                   size(M)

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

SYSAUX                                250

UNDOTBS1                              210

USERS                                  50

SYSTEM                                480

--查看临时数据文件大小

SQL> select tablespace_name,sum(bytes)/1024/1024 "size(M)" from dba_temp_files group by tablespace_name ;

TABLESPACE_NAME                   size(M)

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

TEMP                                   25

--查看表空间已经使用空间大小

SQL> select tablespace_name,sum(bytes)/1024/1024 "used(M)" from dba_segments group by tablespace_name order by tablespace_name;

TABLESPACE_NAME                   used(M)

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

SYSAUX                            238.125

SYSTEM                           476.8125

UNDOTBS1                          20.1875

USERS                                .625

--查看表空间剩余空间大小,发现系统表空间所剩不多了

SQL> select tablespace_name,sum(bytes)/1024/1024 "free(M)" from dba_free_space group by tablespace_name order by tablespace_name;

TABLESPACE_NAME                   free(M)

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

SYSAUX                             12.125

SYSTEM                             3.125

UNDOTBS1                           189.75

USERS                             49.3125

--查看临时表空间使用情况

SQL> select tablespace_name,sum(bytes_used)/1024/1024 "used(M)",sum(bytes_free)/1024/1024 "free(M)" from v$temp_space_header group by tablespace_name;

TABLESPACE_NAME                   used(M)    free(M)

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

TEMP                                    1         24

--增加系统表空间大小

SQL> alter database datafile '/oradata/lianxi/system01.dbf' resize 500M;

Database altered.

SQL> select tablespace_name,sum(bytes)/1024/1024 "size(M)" from dba_data_files group by tablespace_name;

TABLESPACE_NAME                   size(M)

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

SYSAUX                                250

UNDOTBS1                              210

USERS                                  50

SYSTEM                                500


删除用户和表空间:

drop user k3admin

再删除表空间

drop tablespace K3CLOUD_DATA including contents and datafiles;

drop tablespace K3CLOUD_DATA_TEMP including contents and datafiles;


drop user clouduser cascade

drop tablespace K3CLOUD6_DATA including contents and datafiles;

drop tablespace CLOUD6_DATA_TEMP including contents and datafiles;


查看连接及清除连接

select username,sid,serial# from v$session 

alter system kill session '75,3259' 

alter system kill session '9,79' 


转自:

http://blog.sina.com.cn/s/blog_697e5aec010114tn.html

你可能感兴趣的:(oracle,操作,表空间)