Dữ liệu LOB rất khó quản lý nhưng nếu hiểu bản chất và thao tác 1 vài lần thì lại đơn giản, sau khi đọc xong bài viết này bạn đã có trong tay các câu lệnh thường dùng nhất về LOB:

CHECK 
 | 
  
-- D/s View 
select * from dba_lobs; 
select * from dba_lob_partitions; 
select * from
  dba_lob_subpartitions; 
select * from dba_segments where
  segment_type like '%LOB%'; 
-- Size
  segment_name, table, tablespace 
select c.*, d.tablespace_name from
  (select a.owner,b.table_name,b.column_name, a."GB", b.segment_name
  from (select owner, segment_Name, round(sum(bytes)/1024/1024/1024,2)
  "GB" from dba_segments 
where 
--owner in ('BINHTV_OWNER') and 
segment_type like '%LOB%' 
--and tablespace_name='DATA_LOB' 
group by owner, segment_name 
order by owner, segment_name) a, 
(select owner, table_name,
  column_name,segment_name from dba_lobs 
where table_name not like '%$' 
--where owner in ('BINHTV_OWNER') 
group by owner,
  table_name,column_name, segment_name) b 
where a.owner=b.owner and
  a.segment_Name=b.segment_name and a.gb>10) c, (select distinct owner,
  segment_name, tablespace_name from dba_segments) d 
where c.owner=d.owner and
  c.segment_name=d.segment_name 
order by
  d.tablespace_name,c.owner,c."GB"; 
-- Theo doi tang truong TBS 
SELECT  a.tablespace_name,100
  - ROUND ( (NVL (b.bytes_free, 0) / a.bytes_alloc) * 100)
  "%Usage",   ROUND 
(a.bytes_alloc / 1024 / 1024)
  "Size MB",   ROUND (NVL (b.bytes_free, 0) / 1024 /
  1024) "Free MB", 
      (ROUND
  (a.bytes_alloc / 1024 / 1024)- ROUND (NVL (b.bytes_free, 0) / 1024 / 1024))
  "Used MB", ROUND ( (NVL (b.bytes_free, 0) / a.bytes_alloc) * 100)
  "%Free", ROUND (maxbytes / 1048576)  "Max MB", 
       ROUND
  (ROUND ( (a.bytes_alloc - NVL (b.bytes_free, 0)) / 1024 /
  1024)/  ROUND (maxbytes / 1048576) * 100) "%Used of Max" 
  FROM
  (  SELECT f.tablespace_name, SUM (f.bytes)
  bytes_alloc,  SUM (DECODE (f.autoextensible, 'YES', f.maxbytes,
  'NO', f.bytes)) maxbytes 
            FROM
  dba_data_files f 
        GROUP
  BY tablespace_name) a, 
       (  SELECT
  f.tablespace_name, SUM (f.bytes) bytes_free  FROM dba_free_space
  f  GROUP BY tablespace_name) b 
 WHERE a.tablespace_name =
  b.tablespace_name(+) and a.tablespace_name in ('DATA_LOB') 
 order by "%Used of
  Max" desc; 
-- D/s segment_name cua table 
select a.*, b.* from (select
  owner, segment_Name, round(sum(bytes)/1024/1024/1024,2) "GB" from
  dba_segments 
where 
--owner in ('BINHTV_OWNER') and 
segment_type like '%LOB%' 
--and tablespace_name='DATA_LOB' 
group by owner, segment_name 
order by owner, segment_name) a, 
(select owner, table_name,
  column_name,segment_name from dba_lobs 
where table_name not like '%$' 
--where owner in ('BINHTV_OWNER') 
group by owner,
  table_name,column_name, segment_name) b 
where a.owner=b.owner and a.segment_Name=b.segment_name 
order by a."GB" desc; 
--Check thong tin phan vung LOB 
select * from dba_segments where 
--owner in ('BINHTV_OWNER') and 
segment_type like '%LOB%'  
--and tablespace_name='DATA_LOB' 
order by owner, segment_name,
  partition_name; 
-- Size LOB:  
select
  round(sum(bytes)/1024/1024/1024,2) "GB" from dba_segments where 
--owner in ('BINHTV_OWNER') and 
segment_type like '%LOB%'  
--and tablespace_name='DATA_LOB' 
order by owner, segment_name,
  partition_name; 
-- Size theo TBS DATA_LOB ,
  DATA   , CCGW_CLOB   
select
  tablespace_name,round(sum(bytes)/1024/1024/1024,2) "GB" from
  dba_segments where 
--owner in ('BINHTV_OWNER') and 
segment_type like '%LOB%'  
--and tablespace_name='DATA_LOB' 
group by tablespace_name 
order by "GB" desc; 
-- Size >100G theo segment_name 
select owner, segment_Name,
  round(sum(bytes)/1024/1024/1024,2) "GB" from dba_segments 
where 
--owner in ('BINHTV_OWNER') and 
segment_type like '%LOB%' 
--and tablespace_name='DATA_LOB' 
group by owner, segment_name 
order by "GB" desc; 
 | 
 
Truy xuất CLOB 
 | 
  
declare 
    l_data
  varchar2(10000); 
    l_clob
  clob; 
begin 
    select
  in_message into l_clob from CUS_OWNER.API_AUDIT_LOG where id=8108941; 
    l_data
  := dbms_lob.substr( l_clob, 4245, 1 ); 
    dbms_output.put_line(
  'length = ' || length(l_data) ); 
    dbms_output.put_line(
  'l_data = ' || l_data ); 
end; 
 | 
 
Chi tiết cách dọn dẹp dữ liệu lob      | Link: https://www.tranvanbinh.vn/2020/12/quan-ly-du-lieu-lob.html | 
Hy vọng hữu ích với bạn.
* KHOÁ HỌC ORACLE DATABASE A-Z ENTERPRISE trực tiếp từ tôi giúp bạn bước đầu trở thành những chuyên gia DBA, đủ kinh nghiệm đi thi chứng chỉ OA/OCP, đặc biệt là rất nhiều kinh nghiệm, bí kíp thực chiến trên các hệ thống Core tại VN chỉ sau 1 khoá học.
* CÁCH ĐĂNG KÝ: Gõ (.) hoặc để lại số điện thoại hoặc inbox https://m.me/tranvanbinh.vn hoặc Hotline/Zalo 090.29.12.888
* Chi tiết tham khảo:
https://bit.ly/oaz_w
=============================
KẾT NỐI VỚI CHUYÊN GIA TRẦN VĂN BÌNH:
📧 Mail: binhoracle@gmail.com
☎️ Mobile: 0902912888
⚡️ Skype: tranbinh48ca
👨 Facebook: https://www.facebook.com/BinhOracleMaster
👨 Inbox Messenger: https://m.me/101036604657441 (profile)
👨 Fanpage: https://www.facebook.com/tranvanbinh.vn
👨 Inbox Fanpage: https://m.me/tranvanbinh.vn
👨👩 Group FB: https://www.facebook.com/groups/DBAVietNam
👨 Website: https://www.tranvanbinh.vn
👨 Blogger: https://tranvanbinhmaster.blogspot.com
🎬 Youtube: http://bit.ly/ytb_binhoraclemaster
👨 Tiktok: https://www.tiktok.com/@binhoraclemaster?lang=vi
👨 Linkin: https://www.linkedin.com/in/binhoracle
👨 Twitter: https://twitter.com/binhoracle
👨 Địa chỉ: Tòa nhà Sun Square - 21 Lê Đức Thọ - Phường Mỹ Đình 1 - Quận Nam Từ Liêm - TP.Hà Nội
=============================
Quản lý dữ liệu LOB trong Oracle Databasehọc oracle database, Tự học Oracle, Tài liệu Oracle 12c tiếng Việt, Hướng dẫn sử dụng Oracle Database, Oracle SQL cơ bản, Oracle SQL là gì, Khóa học Oracle Hà Nội, Học chứng chỉ Oracle ở đầu, Khóa học Oracle online,khóa học pl/sql, học dba, học dba ở việt nam, khóa học dba, khóa học dba sql, tài liệu học dba oracle, Khóa học Oracle online, học oracle sql, học oracle ở đâu tphcm, học oracle bắt đầu từ đâu, học oracle ở hà nội, oracle database tutorial, oracle database 12c, oracle database là gì, oracle database 11g, oracle download, oracle database 19c, oracle dba tutorial, oracle tunning, sql tunning , oracle 12c, oracle multitenant, Container Databases (CDB), Pluggable Databases (PDB), oracle cloud, oracle security, oracle fga, audit_trail, oracle dataguard, oracle goldengate, mview, oracle exadata, oracle weblogic, middleware, hoc solaris, hoc linux, hoc aix, unix, oracle oca, oracle ocp, oracle ocm