All Blocking sessions
--------------------------
select sid "waiter",a.inst_id "Waiting_Inst", username, a.sql_id "Blocked sql",
b.sql_text,blocking_session "blocker",blocking_instance "Blocking_Inst",
seconds_in_wait "secs wait", wait_time
from gv$session a , gv$sql b
where state in ('WAITING')
and wait_class != 'Idle'
and a.sql_id=b.sql_id
and a.inst_id=b.inst_id and blocking_session is not null
order by seconds_in_wait desc;
Blocked sessions
-------------------------
select sid "waiter",a.inst_id "Waiting_Inst", username, a.sql_id "Blocked sql",
b.sql_text,blocking_session "blocker",blocking_instance "Blocking_Inst",
seconds_in_wait "secs wait", wait_time
from gv$session a , gv$sql b
where state in ('WAITING')
and wait_class != 'Idle'
and a.sql_id=b.sql_id
and a.inst_id=b.inst_id and blocking_session is not null
and a.blocking_session not in (
select sid
from gv$session a , gv$sql b
where state in ('WAITING')
and wait_class != 'Idle'
and a.sql_id=b.sql_id
and a.inst_id=b.inst_id and blocking_session is not null))
Blocked Rows
------------------
SQL> column object_name format a30
SQL> SELECT do.owner,do.object_name ,
s.row_wait_obj# ,
s.row_wait_file# ,
s.row_wait_block#,
s.row_wait_row# ,
dbms_rowid.rowid_create ( 1, data_object_id, rfile#, ROW_WAIT_BLOCK#, ROW_WAIT_ROW# )
FROM gv$session s,
dba_objects do,
v$datafile v
WHERE s.blocking_session = 582
AND s.row_wait_obj# = do.object_id
AND s.row_wait_file# = v.file#
;
DECLARE
ReplyDeletehdnl NUMBER;
BEGIN
hdnl := DBMS_DATAPUMP.OPEN( operation => 'EXPORT', job_mode => 'SCHEMA', job_name=> NULL,version=>'12.1');
DBMS_DATAPUMP.ADD_FILE( handle => hdnl, filename => 'tm_refresh_tmtbls_06082022.dmp', directory => 'DATA_PUMP_DIR', filetype => dbms_datapump.ku$_file_type_dump_file);
DBMS_DATAPUMP.ADD_FILE( handle => hdnl, filename => 'tm_refresh_tmtbls_06082022.log', directory => 'DATA_PUMP_DIR', filetype => dbms_datapump.ku$_file_type_log_file);
dbms_datapump.metadata_filter( handle => hdnl,name => 'SCHEMA_EXPR',value => '= ''TMTBLS''');
dbms_datapump.metadata_filter(handle => hdnl,name => 'NAME_EXPR',value => 'IN (''TERRITORY'',''TERRITORY_VERSION'',''WORKSPACE'',''TERRITORY_RULE'',''RULE'',''RULE_GEO'',''RULE_VERTICAL'',''RULE_DUNS'',''HOME_SEGMENT'',''ANALYTICS_QUERY'',''ANALYTICS_FIELD'',''ANALYTICS_FIELD_VALUE'',''REMARKS'',''TERRITORY_CONTACT'')', object_type => 'TABLE');
DBMS_DATAPUMP.START_JOB(hdnl);
END;
/
Above is the syntax , Make sure to change the dump file name , logfile name and the tables list , schema name accordingly.
7. You can check the log using – select * from table(rdsadmin.rds_file_util.read_text_file(p_directory => 'DATA_PUMP_DIR',p_filename => 'tm_refresh_extdata_05192022.log'));
8. if there are multiple schema exports you need to run export multiple times with above syntax.
9. Shipping of file from PROD to PLE: Change dumpfile name
BEGIN
DBMS_FILE_TRANSFER.PUT_FILE(
source_directory_object => 'DATA_PUMP_DIR',
source_file_name => 'tm_refresh_tmtbls_06082022.dmp',
destination_directory_object => 'DATA_PUMP_DIR',
destination_file_name => 'tm_refresh_tmtbls_06082022.dmp',
destination_database => 'ple_uat_rds'
);
END;
/
10. now in PLE run below for import. Please change schema name, tables list , dumpfile name accordingly. You can also run above sql to check the log.
DECLARE
hdnl NUMBER;
BEGIN
hdnl := DBMS_DATAPUMP.OPEN( operation => 'IMPORT', job_mode => 'SCHEMA', job_name=> NULL,version=>'12.1');
DBMS_DATAPUMP.ADD_FILE( handle => hdnl, filename => 'tm_refresh_tmtbls_06082022.dmp', directory => 'DATA_PUMP_DIR', filetype => dbms_datapump.ku$_file_type_dump_file);
DBMS_DATAPUMP.ADD_FILE( handle => hdnl, filename => 'tm_refresh_tmtbls_06082022.log', directory => 'DATA_PUMP_DIR', filetype => dbms_datapump.ku$_file_type_log_file);
dbms_datapump.metadata_filter( handle => hdnl,name => 'SCHEMA_EXPR',value => '= ''TMTBLS''');
dbms_datapump.metadata_filter(handle => hdnl,name => 'NAME_EXPR',value => 'IN (''TERRITORY'',''TERRITORY_VERSION'',''WORKSPACE'',''TERRITORY_RULE'',''RULE'',''RULE_GEO'',''RULE_VERTICAL'',''RULE_DUNS'',''HOME_SEGMENT'',''ANALYTICS_QUERY'',''ANALYTICS_FIELD'',''ANALYTICS_FIELD_VALUE'',''REMARKS'',''TERRITORY_CONTACT'')', object_type => 'TABLE');
DBMS_DATAPUMP.SET_PARAMETER(hdnl,'TABLE_EXISTS_ACTION','REPLACE');
DBMS_DATAPUMP.START_JOB(hdnl);
END;
/