using LONG datatype in sql

In order to use LONG datatype, first convert to xml, then extract value from xml.
One example is DBA_TAB_PARTITIONS.HIGH_VALUE,

with xml as (
  select dbms_xmlgen.getxmltype('
         select table_owner,
                table_name, 
                tablespace_name,
                partition_name,
                partition_position,
                round((blocks * 8192)/1024/1024,0) size_mb, 
                high_value 
           from dba_tab_partitions 
          where table_name = ''&table'' 
            and table_owner = ''&schema''') as x
  from   dual)
  select  extractvalue(rws.object_value, '/ROW/TABLE_OWNER') table_owner,
          extractvalue(rws.object_value, '/ROW/TABLE_NAME') table_name,
          extractvalue(rws.object_value, '/ROW/TABLESPACE_NAME') tablespace_name,
          extractvalue(rws.object_value, '/ROW/PARTITION_NAME') partition_name,
          extractvalue(rws.object_value, '/ROW/PARTITION_POSITION') partition_POSITION,
          extractvalue(rws.object_value, '/ROW/SIZE_MB') size_mb,
          extractvalue(rws.object_value, '/ROW/HIGH_VALUE') high_value
   from   xml x,
          table(xmlsequence(extract(x.x, '/ROWSET/ROW'))) rws 

oracle DML session progress

To find out the progress of a DML session, you can run the following query.

select s.inst_id,
       s.username,
       sid,
       serial#, 
       substr(s.program, 1, 19) program, 
       t.used_urec,
       t.used_ublk
  from gv$session s, 
       gv$transaction t
where s.saddr = t.ses_addr
;

exchange table partition

The basic steps are, create temporary table, insert data into temporary table, create all indexes on temporary table, exchange partition, drop temporary table.

create table sales.weekly_sale_part_891 
tablespace tbsp_name;
as 
select * 
from sales.weekly_sale 
where 1=2
;

insert /*+ append */ 
into sales.weekly_sale_part_891  
select * 
from sales.weekly_sale partition (SYS_P891) 
;

create index sales.weekly_sale_idx_p891 
on sales.weekly_sale_part_891 (c1, c2, ..) 
tablespace tbsp_name;
;


alter table sales.weekly_sale 
exchange partition SYS_P891 
with table sales.weekly_sale_part_891
; 

alter index sales.weekly_sale_idx
rebuild partition SYS_P891 
tablespace tbsp_name; 
;

drop table sales.weekly_sale_part_891;