首先介紹一下項目背景,這是一個java的后端平臺,運行在win2008server平臺上,主要存圖片和視頻的,占空間比較大,Oracle數(shù)據(jù)庫(你懂的,崩潰的節(jié)奏)。
一張圖片表主要用于存儲blob類型的圖片數(shù)據(jù),硬盤中共也就800G,發(fā)現(xiàn)單個表空間數(shù)據(jù)文件增長到30G左右,硬盤就剩下30G左右的空間,馬上就要爆表了,領導很是著急,催的特別急,無奈我是一臉懵逼,也沒有詳細的記錄文檔,每張表都不知道干嘛的。
最后通過請教當年寫項目的大佬,得到方案,備份一年的數(shù)據(jù),truncate表,直接刪除表空間,然后重新建立表空間,下面記錄了一些當時的用的sql語句。

牟定ssl適用于網(wǎng)站、小程序/APP、API接口等需要進行數(shù)據(jù)傳輸應用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)建站的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18980820575(備注:SSL證書合作)期待與您的合作!
查看各個表空間大小
select a.tablespace_name, round(a.total_size) "total_size(MB)",
round(a.total_size)-round(b.free_size,3) "used_size(MB)",
round(b.free_size,3) "free_size(MB)", round(b.free_size/total_size*100,2)||'%' free_rate
from ( select tablespace_name, sum(bytes)/1024/1024 total_size
from dba_data_files
group by tablespace_name ) a,
( select tablespace_name, sum(bytes)/1024/1024 free_size
from dba_free_space
group by tablespace_name ) b
where a.tablespace_name = b.tablespace_name(+);
查看表空間
select tablespace_name,file_id,file_name,
round(bytes/(1024*1024),0) total_space
from dba_data_files
order by tablespace_name
select file_name,autoextensible,increment_by from dba_data_files
where tablespace_name='表空間名稱'
清空數(shù)據(jù) 有可能表空間仍沒有釋放,可以使用如下語句:
truncate table pecprocesspic
alter table pecprocesspic deallocate UNUSED KEEP 0;
刪除表空間,刪除無任何數(shù)據(jù)對象的表空間
drop tablespace wz_img
刪除有任何數(shù)據(jù)對象的表空間(操作需謹慎,必須備份好數(shù)據(jù)!)
drop tablespace wz_img including contents and datafiles;
創(chuàng)建表空間
create tablespace 表空間名稱 datafile 'D:\app\Administrator\oradata\orcl\表空間文件名稱.ora' size 512m autoextend on next 256m maxsize unlimited;
添加表空間文件
alter tablespace 表空間文件 add datafile 'D:\app\Administrator\oradata\orcl\表空間文件名稱.ora' size 512m autoextend on next 256m maxsize unlimited;
這是一些重要的sql語句,其他的備份還原就不寫了,都是通過pl/sql操作的,不難,很大的數(shù)據(jù)量,備份了將近七天左右,還原了三天左右。
本文題目:記一次Oracle釋放表空間,還原數(shù)據(jù)實操
網(wǎng)站網(wǎng)址:http://www.chinadenli.net/article8/gcccop.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供自適應網(wǎng)站、商城網(wǎng)站、面包屑導航、外貿(mào)網(wǎng)站建設、服務器托管、定制網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)