SELECT 'drop table ' || owner_name || '.' || job_name || ';' FROM dba_datapump_jobs WHERE state='NOT RUNNING' and attached_sessions=0; exec the sql
Oracle Technical
Posts about Oracle databases
Oracle – Using ASH to Monitor Temporary Tablespace Usage
Using ASH to Monitor Temporary Tablespace Usage
To use ASH (Active Session History) to monitor temporary tablespace usage use SQL similar to the query below. Detect the space used by queries.
SELECT ASH.inst_id, ASH.user_id, ASH.session_id sid, ASH.session_serial# serial#, ASH.sql_id, ASH.sql_exec_id, ASH.sql_opname, ASH.module, MIN(sample_time) sql_start_time, MAX(sample_time) sql_end_time, ((CAST(MAX(sample_time) AS DATE)) - (CAST(MIN(sample_time) AS DATE))) * (3600*24) etime_secs , ((CAST(MAX(sample_time) AS DATE)) - (CAST(MIN(sample_time) AS DATE))) * (60*24) etime_mins , MAX(temp_space_allocated)/(1024*1024) max_temp_mb FROM gv$active_session_history ASH WHERE ASH.session_type = 'FOREGROUND' AND ASH.sql_id IS NOT NULL --AND sample_time BETWEEN to_timestamp('01-04-2019 10:00', 'DD-MM-YYYY HH24:MI') AND to_timestamp('13-04-2019 12:00', 'DD-MM-YYYY HH24:MI') AND sample_time > systimestamp - 3 GROUP BY ASH.inst_id, ASH.user_id, ASH.session_id, ASH.session_serial#, ASH.sql_id, ASH.sql_opname, ASH.sql_exec_id, ASH.module HAVING MAX(temp_space_allocated) > 10000 order by 9 desc
Oracle – RMAN commands
delete archivelog all backed up 1 times to sbt_tape;
delete archivelog all completed before 'sysdate -1';
delete noprompt archivelog all;
....until time "to_date('2018-03-13 14:00:07','YYYY-MM-DD HH24:MI:SS')";
Oracle – Identify Locked Objects
Identify Locked Database Objects – Oracle
select b.owner, b.object_name, a.oracle_username, a.os_user_name from gv$locked_object a, all_objects b where a.object_id = b.object_id select * from gv$locked_object select c.owner, c.object_name, c.object_type, b.sid, b.serial#, b.status, b.osuser, b.machine from gv$locked_object a , gv$session b, dba_objects c where b.sid = a.session_id and a.object_id = c.object_id and a.inst_id = b.inst_id SELECT Decode(request, 0, 'Holder: ', 'Waiter: ') ||vl.sid sess, status,id1,id2,lmode,request,vl.TYPE FROM v$lock vl,v$session vs WHERE ( id1, id2, vl.TYPE ) IN (SELECT id1, id2, TYPE FROM v$lock WHERE request > 0) AND vl.sid = vs.sid ORDER BY id1, request
Oracle – 18c XE Flashback Pluggable Database Session
18c XE Flashback Pluggable Database Session
SQL> sho parameters reco NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ control_file_record_keep_time integer 7 db_recovery_file_dest string db_recovery_file_dest_size big integer 0 db_unrecoverable_scn_tracking boolean TRUE recovery_parallelism integer 0 remote_recovery_file_dest string SQL> host df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 4.8G 0 4.8G 0% /dev tmpfs 4.8G 0 4.8G 0% /dev/shm tmpfs 4.8G 26M 4.8G 1% /run tmpfs 4.8G 0 4.8G 0% /sys/fs/cgroup /dev/mapper/ol-root 45G 24G 21G 54% / /dev/xvda1 1014M 399M 616M 40% /boot tmpfs 974M 12K 974M 1% /run/user/42 tmpfs 974M 0 974M 0% /run/user/0 tmpfs 974M 0 974M 0% /run/user/54321 SQL> sho parameters pfile NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ spfile string /opt/oracle/product/18c/dbhome XE/dbs/spfileXE.ora SQL> alter system set db_recovery_file_dest_size=20G scope=BOTH; System altered. SQL> alter system set db_recovery_file_dest='/opt/oracle/oradata/XE/FRA' scope=BOTH; System altered. SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. SQL> startup mount ORACLE instance started. Total System Global Area 1610612704 bytes Fixed Size 8896480 bytes Variable Size 520093696 bytes Database Buffers 1073741824 bytes Redo Buffers 7880704 bytes Database mounted. SQL> alter database archivelog; Database altered. SQL> alter database flashback on; Database altered. SQL> alter database open; Database altered. SQL> set lines 170 SQL> select * from v$flash_recovery_area_usage; FILE_TYPE PERCENT_SPACE_USED PERCENT_SPACE_RECLAIMABLE NUMBER_OF_FILES CON_ID ----------------------- ------------------ ------------------------- --------------- ---------- CONTROL FILE 0 0 0 0 REDO LOG 0 0 0 0 ARCHIVED LOG 0 0 0 0 BACKUP PIECE 0 0 0 0 IMAGE COPY 0 0 0 0 FLASHBACK LOG 1.95 0 2 0 FOREIGN ARCHIVED LOG 0 0 0 0 AUXILIARY DATAFILE COPY 0 0 0 0 8 rows selected. SQL> SELECT flashback_on FROM v$database; FLASHBACK_ON ------------------ YES SQL> select * from v$flash_recovery_area_usage; FILE_TYPE PERCENT_SPACE_USED PERCENT_SPACE_RECLAIMABLE NUMBER_OF_FILES CON_ID ----------------------- ------------------ ------------------------- --------------- ---------- CONTROL FILE 0 0 0 0 REDO LOG 0 0 0 0 ARCHIVED LOG 0 0 0 0 BACKUP PIECE 0 0 0 0 IMAGE COPY 0 0 0 0 FLASHBACK LOG 1.95 0 2 0 FOREIGN ARCHIVED LOG 0 0 0 0 AUXILIARY DATAFILE COPY 0 0 0 0 8 rows selected. SQL> SELECT flashback_on FROM v$database; FLASHBACK_ON ------------------ YES SQL> alter session set container=xepdb1; Session altered. SQL> create restore point PDB1_GRP1 guarantee flashback database; Restore point created. SQL> create table tw (id number); Table created. SQL> insert into tw values(1); 1 row created. SQL> commit; Commit complete. SQL> shutdown immediate Pluggable Database closed. SQL> flashback pluggable database xepdb1 to restore point PDB1_GRP1; Flashback complete. SQL> show con_name CON_NAME ------------------------------ XEPDB1 SQL> startup nomount -- we are in the xepdb1 container SQL> select name from v$pdbs; NAME -------------------------------------------------------- XEPDB1 SQL> alter pluggable database open resetlogs; Pluggable database altered. SQL> select * from dual; D - X SQL> desc tw ERROR: ORA-04043: object tw does not exist SQL> select name from v$pdbs; NAME ---------------------------------------------------------------- XEPDB1 SQL> ALTER SESSION SET container = cdb$root; Session altered. SQL> select name from v$pdbs; NAME --------------------------------------------------------------- PDB$SEED XEPDB1 PDB2
Oracle – RMAN backups
select object_name from dba_objects where object_name like '%RMAN%' select * from gv$backup_set order by completion_time desc select * from v$rman_backup_job_details order by start_time desc select start_time, end_time, input_bytes,output_bytes, status, input_type,elapsed_seconds, input_bytes_display from v$rman_backup_job_details order by start_time desc
Oracle – Install Clusterware – Test udp multicast on Private Interconnect (and get maximum MTU)
Test Multicast on Private Interconnect (and get maximum MTU)
There are several ways to test multicast communication using udp. I was debugging an oracle Clusterware installation – the clusterware on the second node would not completely start (specifically ocssd and crsd would not start on node2).
All standard/published Oracle tests passed. See Oracle – Clusterware Installation and Configuration
Without going into too much detail, the Clusterware daemons would not start on the second node because the MTU on some of the switches in the network was not configured correctly.
The two java programs below can be used to test whether multicast is working on the network between two servers. More specifically, they can be used to determine the maximum MTU that can be used between the two servers, taking into consideration all network elements (NICs, switches, routers).
Switches/routers may be configured to support Jumbo frames. MTU 9000 (maybe set to 9150 on switch/routers)
The default MTU on switches may be 1400!
Normally, the NICs on the Linux server are set to 1500 MTU.
Private interconnect NICs/bond can be set to 9000 if all intermediate network elements support and are configured for Jumbo frames
MultiCastTestReceiveLoop.java
This program is used to receive udp datagrams on a socket (max. 9150 – covers Jumbo frames).
The communication follows a similar path as that used between Oracle Clusterware processes.
To compile:
To execute:
import sun.net.*; import java.net.*; public class MultiCastTestReceiveLoop { public MultiCastTestReceiveLoop() { MultiCastTestReceiveLoop MultiCastTestReceiveLoop = new MultiCastTestReceiveLoop(42424,"230.0.1.0"); } public MultiCastTestReceiveLoop(int port,String group) { try { while (true) { // Create the socket and bind it to port 'port'. MulticastSocket s = new MulticastSocket(port); // join the multicast group s.setNetworkInterface(NetworkInterface.getByName("<interconnect interface>")); s.joinGroup(InetAddress.getByName(group)); byte buf[] = new byte[9500]; DatagramPacket pack = new DatagramPacket(buf, buf.length); s.receive(pack); System.out.println("Received data from: " + pack.getAddress().toString() + ":" + pack.getPort() + " with length: " + pack.getLength()); System.out.write(pack.getData(),0,pack.getLength()); System.out.println(); s.leaveGroup(InetAddress.getByName(group)); s.close(); } // end while true } // Adding just a catch-all catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) { if (args.length == 2) { MultiCastTestReceiveLoop MultiCastTestReceiveLoop = new MultiCastTestReceiveLoop(Integer.parseInt(args[1]),args[0]); } else { MultiCastTestReceiveLoop MultiCastTestReceiveLoop = new MultiCastTestReceiveLoop(); } } }
MultiCastTestSend.java
This program is used to send udp datagrams on a socket. The buffer is filled with the letter ‘a’ (length set with the nbytes argument on the command line
The communication follows a similar path as that used between Oracle Clusterware processes.
To compile:
To execute:
import sun.net.*; import java.net.*; public class MultiCastTestSend { public MultiCastTestSend() { MultiCastTestSend multiCastTestSend = new MultiCastTestSend(42424,"230.0.1.0",10); } public MultiCastTestSend(int port,String group,int nbytes) { int ttl = 1; try { // Create the socket MulticastSocket s = new MulticastSocket(); // set LAN interface to send on s.setNetworkInterface(NetworkInterface.getByName("<interconnect interface>")); // Fill the buffer with some data byte buf[] = new byte[nbytes]; for (int i=0; i<buf.length; i++) buf[i] = (byte)i; // Create a DatagramPacket DatagramPacket pack = new DatagramPacket(buf, buf.length, InetAddress.getByName(group), port); s.setTimeToLive(ttl); s.send(pack); // And when we have finished sending data close the socket System.out.println("Sent bytes to " + pack.getAddress().toString()); s.close(); } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) { if (args.length == 3) { MultiCastTestSend multiCastTestSend = new MultiCastTestSend(Integer.parseInt(args[1]),args[0],Integer.parseInt(args[2])); } else { MultiCastTestSend multiCastTestSend = new MultiCastTestSend(); } } }
Oracle – Monitor TEMP Tablespace
Monitor TEMP Tablespace with a DBMS_SCHEDULER job
I was faced with a situation in which a process (Oracle pl/sql procedure within a package, scheduled outside Oracle in the evenings) was exhausting the TEMP tablespace. In order to investigate, the following procedure was used to monitor TEMP tablespace usage during the period of time the job was executed. This allowed quick identification of the offending user and SQL that was causing TEMP tablesace exhaustion.
Code is quick and dirty, no exception handling. I’m assuming the executing user has all the required privileges. There are other ways to investigate this, but this works.
Create a table to store data
CREATE TABLE TEMPDATA ( CTIME TIMESTAMP(6) WITH TIME ZONE, TABLESPACE VARCHAR2(30), TEMP_SIZE VARCHAR2(41), INSTANCE NUMBER, SID_SERIAL VARCHAR2(81), USERNAME VARCHAR2(30), PROGRAM VARCHAR2(48), STATUS VARCHAR2(8), SQL_ID VARCHAR2(13) )
Create the procedure
CREATE OR REPLACE procedure colltempdata as begin begin insert into tempdata SELECT systimestamp ctime, b.tablespace, ROUND(((b.blocks*p.value)/1024/1024),2)||'M' AS temp_size, a.inst_id as Instance, a.sid||','||a.serial# AS sid_serial, NVL(a.username, '(oracle)') AS username, a.program, a.status, a.sql_id FROM sys.gv$session a, sys.gv$sort_usage b, sys.gv$parameter p WHERE p.name = 'db_block_size' AND a.saddr = b.session_addr AND a.inst_id=b.inst_id AND a.inst_id=p.inst_id; end; end; /
Create a job to execute the procedure
In this example, execute every minute for a specfied time period
begin DBMS_SCHEDULER.CREATE_JOB ( job_name => 'colltempdatajob6', job_type => 'PLSQL_BLOCK', job_action => 'begin colltempdata;commit;end;', start_date => timestamp '2018-07-04 21:30:00', repeat_interval => 'FREQ=MINUTELY;INTERVAL=1;', end_date => timestamp '2018-07-04 22:45:00', enabled => TRUE); end;
SQL to display jobs, check size of data, and query the collected data
-- display job details select job_name, start_date, run_count, last_start_date, next_run_date from dba_scheduler_jobs where job_name like 'COLLTEMPDATAJOB%' order by start_date -- check size of data select sum(bytes)/1024/1024/1024 from dba_segments where segment_name = 'TEMPDATA' -- Query data collected select * from tempdata order by ctime desc
Oracle – Automatic Workload Respository AWR
AWR, Automatic Workload Respository
The Oracle AWR, Automatic Workload Respository, is tored in the SYSAUX tablespace. This post conatians information useful for purging/cleaning the AWR when it becomes large due to failure of cleanup jobs to remove partitions in the large AWR table, e.g. WRH$_ACTIVE_SESSION_HISTORY. Mainly Oracle 12c release 1.
-- check ASH history compared to retention period select sysdate - a.sample_time ash, sysdate - s.begin_interval_time snap, c.RETENTION from sys.wrm$_wr_control c, ( select db.dbid, min(w.sample_time) sample_time from sys.v_$database db, sys.Wrh$_active_session_history w where w.dbid = db.dbid group by db.dbid ) a, ( select db.dbid, min(r.begin_interval_time) begin_interval_time from sys.v_$database db, sys.wrm$_snapshot r where r.dbid = db.dbid group by db.dbid ) s where a.dbid = s.dbid and c.dbid = a.dbid;
-- How much space is being used? SELECT occupant_name "Item", space_usage_kbytes/1048576 "Space Used (GB)", schema_name "Schema", move_procedure "Move Procedure" FROM v$sysaux_occupants WHERE occupant_name in ('SM/AWR','SM/OPTSTAT') ORDER BY 1
-- Get orphaned ASH rows SELECT COUNT(1) Orphaned_ASH_Rows FROM wrh$_active_session_history a WHERE NOT EXISTS (SELECT 1 FROM wrm$_snapshot WHERE snap_id = a.snap_id AND dbid = a.dbid AND instance_number = a.instance_number );
-- check ASH history compared to retention period select sysdate - a.sample_time ash, sysdate - s.begin_interval_time snap, c.RETENTION from sys.wrm$_wr_control c, ( select db.dbid, min(w.sample_time) sample_time from sys.v_$database db, sys.Wrh$_active_session_history w where w.dbid = db.dbid group by db.dbid ) a, ( select db.dbid, min(r.begin_interval_time) begin_interval_time from sys.v_$database db, sys.wrm$_snapshot r where r.dbid = db.dbid group by db.dbid ) s where a.dbid = s.dbid and c.dbid = a.dbid;
-- Get current settings select DBID, SNAP_INTERVAL, RETENTION, TOPNSQL from DBA_HIST_WR_CONTROL; select extract( day from snap_interval) *24*60+ extract( hour from snap_interval) *60+ extract( minute from snap_interval ) "Snapshot Interval (minutes)", extract( day from retention) *24*60+ extract( hour from retention) *60+ extract( minute from retention ) "Retention Interval (minutes)" from dba_hist_wr_control
-- Check snapshoits are being created properly SELECT (CASE WHEN NUMTODSINTERVAL((SYSDATE - MAX(CAST(END_INTERVAL_TIME AS DATE))), 'DAY') < SNAP_INTERVAL THEN 'OK AWR Snapshots are being collected' ELSE 'NOK Problems with Snapshot collection' END) "RESULT" FROM DBA_HIST_SNAPSHOT, DBA_HIST_WR_CONTROL GROUP BY SNAP_INTERVAL
-- Disable snapshots BEGIN DBMS_WORKLOAD_REPOSITORY.modify_snapshot_settings( retention => 11520, -- Mins (43200 = 30 Days). Current value retained if NULL.(11520 is 8 days) interval => 0); -- Mins. Current value retained if NULL. If zero --> snapshots are stopped END; / -- Enable snapshots BEGIN DBMS_WORKLOAD_REPOSITORY.modify_snapshot_settings( retention => 43200, -- Minutes (= 30 Days). Current value retained if NULL. (11520 is 8 days) interval => 30); -- Minutes. Current value retained if NULL. If zero --> snapshots are stopped END; /
-- Get Objects at high end of tablespace select * from ( select owner,segment_name, partition_name, segment_type, max((block_id + blocks-1)*8192)/1024/1024 "HWM_MB" from dba_extents where file_id=<file id for SYSAUX (2)> group by owner,segment_name, partition_name, segment_type) where HWM_MB > <Put size here e.g. 10000 for 10G> order by 5 DESC
Move Segments to a temp SYSAUX to reorganize SYSAUX objects
• Move CTXSYS
• Move LogMiner
• Move DBAudit Tables
• Move LOB segments (BLOB and CLOB columns)
• Move Normal tables and rebuild indexes
• Move partitioned tables and rebuild partitioned indexes
• Move tables with LONG columns
• Move nested tables
• Move IOTs
• 12c – HEATMAP
• AQ datapump tables
exec ctxsys.DRI_MOVE_CTXSYS(TBS_NAME=>'SYSAUX_TEMP', PRINT_ONLY=>false) select count(*), segment_type from dba_segments where tablespace_name = 'SYSAUX' and owner = 'CTXSYS' group by segment_type exec SYS.DBMS_LOGMNR_D.SET_TABLESPACE('SYSAUX_TEMP') exec DBMS_AUDIT_MGMT.move_dbaudit_tables('SYSAUX_TEMP') BEGIN dbms_audit_mgmt.set_audit_trail_location( audit_trail_type => dbms_audit_mgmt.audit_trail_unified, audit_trail_location_value => 'SYSAUX_TEMP'); END; / BEGIN DBMS_AUDIT_MGMT.set_audit_trail_location( audit_trail_type => DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD,--this moves table AUD$ audit_trail_location_value => 'SYSAUX_TEMP'); END; / BEGIN DBMS_AUDIT_MGMT.set_audit_trail_location( audit_trail_type => DBMS_AUDIT_MGMT.AUDIT_TRAIL_FGA_STD,--this moves table FGA_LOG$ audit_trail_location_value => 'SYSAUX_TEMP'); END; / None of these move the CLI_ objects PROCEDURE MOVE_DBAUDIT_TABLES Argument Name Type In/Out Default? ------------------------------ ----------------------- ------ -------- AUDIT_TRAIL_TBS VARCHAR2 IN DEFAULT 12c --THIS ONE removed CLI_SWP* (very quickly!) – when the AUDIT objects are moved -- they are recreated in the new tablespace SQL> exec dbms_audit_mgmt.clean_audit_trail(audit_trail_type=>dbms_audit_mgmt.audit_trail_unified,use_last_arch_timestamp=>FALSE); BLOB and CLOB Segments General alter table <owner>.<table_name> move lob(<column name>) store as ( tablespace sysaux_temp ); Find Generate Move LOB Commands SELECT 'alter table '||owner||'.'||TABLE_NAME|| ' move lob('||COLUMN_NAME||') store as (tablespace SYSAUX_TEMP);' "move lob script", DATA_TYPE FROM dba_tab_columns WHERE DATA_TYPE IN ('CLOB','BLOB') AND table_name IN (SELECT table_name FROM dba_tables WHERE tablespace_name='SYSAUX' and partitioned = 'NO' and NESTED = 'NO') and owner = 'SYS' This will generate commands that will work for normal (non-partitioned and non-nested) tables. Partitioned table commands are different Move to SYSAUX_TEMP alter table WRH$_SQL_PLAN move lob(other_xml) store as ( tablespace sysaux_temp ) 12c alter table WRH$_SQLTEXT move lob(SQL_TEXT) store as ( tablespace sysaux_temp ) Move back to SYSAUX alter table WRH$_SQL_PLAN move lob(other_xml) store as ( tablespace sysaux ) 12c alter table WRH$_SQLTEXT move lob(SQL_TEXT) store as ( tablespace sysaux ) alter table WRI$_ADV_RATIONALE move lob(ATTR5) store as ( tablespace sysaux_temp ) alter table WRI$_DBU_FEATURE_USAGE move lob(FEATURE_INFO) store as ( tablespace sysaux_temp ) And for partitioned tables, example: Find the LOB PARTITION name Find the table name from dba_lobs Find the column name by DESC’ing the table select 'alter table <table name> move partition ' ||partition_name||' lob(<column name>) '||' store as (tablespace SYSAUX_TEMP);' from dba_tab_partitions where table_name = '<table name>' select 'alter table WRI$_OPTSTAT_HISTHEAD_HISTORY move partition ' ||partition_name||' lob(EXPRESSION) '||' store as (tablespace SYSAUX_TEMP);' from dba_tab_partitions where table_name = 'WRI$_OPTSTAT_HISTHEAD_HISTORY' Normal Tables and Indexes Generate Table Move (to SYSAUX_TEMP) Scripts select 'alter table '||owner||'.'||segment_name||' move tablespace sysaux_temp;' from dba_segments where segment_type = 'TABLE' and tablespace_name = 'SYSAUX'and owner = 'SYS' Generate Index Rebuild (to SYSAUX_TEMP) Scripts select 'alter index '||owner||'.'||index_name||' rebuild tablespace SYSAUX_TEMP;' from dba_indexes where status = 'UNUSABLE' and tablespace_name = 'SYSAUX' Partitioned tables and Indexes Move table partitions to SYSAUX_TEMP select 'alter table '||owner||'.'||segment_name||' move partition '||partition_name||' tablespace sysaux_temp;' from dba_segments where segment_type = 'TABLE PARTITION' and tablespace_name = 'SYSAUX' order by segment_name Rebuild Index Partitions in SYSAUX_TEMP They become USABLE again and are rebuilt in SYSAUX_TEMP select 'alter index '||index_name|| ' rebuild partition '|| partition_name||' tablespace SYSAUX_TEMP;' from dba_ind_partitions where status = 'UNUSABLE' and tablespace_name = 'SYSAUX' Move to SYSAUX_TEMP select 'alter table '||owner||'.'||segment_name ||' move tablespace SYSAUX_TEMP;' from dba_segments where segment_name like '%==' and tablespace_name = 'SYSAUX' and segment_type = 'NESTED TABLE' Index-Organized Tables IOT Find the table concerned and shrink it Enable row movement on the table first (if not already enabled) Display row_movement select owner,table_name, row_movement from dba_tables where table_name in (select table_name from dba_indexes where index_name like '%IOT%' and tablespace_name = 'SYSAUX') GSMADMIN_INTERNAL – may not be required to move this – see WMSYS CTXSYS – these should have been moved with the move proc but may not have been IOT Indexes alter table AQ$_ALERT_QT_H shrink space cascade; 12c - HEATMAP See MOS Doc ID 2024036.1 HEATMAP Segment Size Is Large In SYSAUX Even When Heatmap=Off (Doc ID 2024036.1) This is not the same as my problem – but the solution to my HEATMAP problem is in this document SQL> show parameter HEAT_MAP; NAME TYPE VALUE ------------------------------------ -------------------------------------------- ------------------------------ heat_map string OFF ALTER SYSTEM SET "_drop_stat_segment"=1 scope=memory; Heatmap is dropped AQ DATAPUMP Tables Examples alter table "AQ$_KUPC$DATAPUMP_QUETAB_2_P" move tablespace sysaux_temp; alter table "AQ$_KUPC$DATAPUMP_QUETAB_2_S" move tablespace sysaux_temp; Tables with LONG columns Display Tables with LONG Columns SELECT TABLE_NAME,COLUMN_NAME,DATA_TYPE FROM dba_tab_columns WHERE DATA_TYPE IN ('LONG','LONG RAW') AND table_name IN (SELECT table_name FROM dba_tables WHERE tablespace_name='SYSAUX') Some tables with long columns do not contain data- these can be truncated directly. For tables with LONG columns that contain data AND there is no data in the LONG column: • create a temporary table with the data without the LONG column(s) • truncate the table • insert the rows back into the table WRI$_ADV_SQLT_PLAN Doc ID 2205210.1 create table SQLT_PLANS_TEMP as select TASK_ID, OBJECT_ID, ATTRIBUTE, PLAN_HASH_VALUE, PLAN_ID,STATEMENT_ID, TIMESTAMP, REMARKS, OPERATION, OPTIONS, OBJECT_NODE, OBJECT_OWNER, OBJECT_NAME, OBJECT_ALIAS, OBJECT_INSTANCE,OBJECT_TYPE,OPTIMIZER,SEARCH_COLUMNS,ID,PARENT_ID,DEPTH,POSITION, COST,CARDINALITY,BYTES,OTHER_TAG,PARTITION_START,PARTITION_STOP,PARTITION_ID, DISTRIBUTION,CPU_COST,IO_COST,TEMP_SPACE,ACCESS_PREDICATES,FILTER_PREDICATES, PROJECTION,TIME,QBLOCK_NAME,OTHER_XML from WRI$_ADV_SQLT_PLANS select count(*) from WRI$_ADV_SQLT_PLANS where other is not null select count(*) from SQLT_PLANS_TEMP select * from SQLT_PLANS_TEMP truncate table WRI$_ADV_SQLT_PLANS insert into WRI$_ADV_SQLT_PLANS select TASK_ID,OBJECT_ID,ATTRIBUTE, PLAN_HASH_VALUE, PLAN_ID,STATEMENT_ID, TIMESTAMP, REMARKS, OPERATION, OPTIONS, OBJECT_NODE, OBJECT_OWNER, OBJECT_NAME, OBJECT_ALIAS, OBJECT_INSTANCE, OBJECT_TYPE,OPTIMIZER, SEARCH_COLUMNS, ID, PARENT_ID, DEPTH,POSITION, COST, CARDINALITY, BYTES, OTHER_TAG,PARTITION_START,PARTITION_STOP,PARTITION_ID, NULL,DISTRIBUTION,CPU_COST, IO_COST,TEMP_SPACE,ACCESS_PREDICATES,FILTER_PREDICATES, PROJECTION,TIME,QBLOCK_NAME, OTHER_XML from SQLT_PLANS_TEMP create table PLAN_temp as select SIGNATURE, CATEGORY, OBJ_TYPE, PLAN_ID, STATEMENT_ID, XPL_PLAN_ID, TIMESTAMP, REMARKS, OPERATION, OPTIONS, OBJECT_NODE, OBJECT_OWNER, OBJECT_NAME, OBJECT_ALIAS, OBJECT_INSTANCE, OBJECT_TYPE, OPTIMIZER, SEARCH_COLUMNS, ID, PARENT_ID, DEPTH, POSITION, COST,CARDINALITY,BYTES,OTHER_TAG,PARTITION_START, PARTITION_STOP,PARTITION_ID,DISTRIBUTION,CPU_COST,IO_COST,TEMP_SPACE, ACCESS_PREDICATES,FILTER_PREDICATES,PROJECTION,TIME,QBLOCK_NAME,OTHER_XML from SQLOBJ$PLAN truncate table SQLOBJ$PLAN insert into SQLOBJ$PLAN select SIGNATURE, CATEGORY, OBJ_TYPE, PLAN_ID, STATEMENT_ID, XPL_PLAN_ID, TIMESTAMP, REMARKS, OPERATION, OPTIONS, OBJECT_NODE,OBJECT_OWNER,OBJECT_NAME,OBJECT_ALIAS,OBJECT_INSTANCE,OBJECT_TYPE, OPTIMIZER,SEARCH_COLUMNS,ID,PARENT_ID,DEPTH,POSITION,COST,CARDINALITY,BYTES,OTHER_TAG, PARTITION_START,PARTITION_STOP,PARTITION_ID,NULL,DISTRIBUTION,CPU_COST,IO_COST,TEMP_SPACE, ACCESS_PREDICATES,FILTER_PREDICATES,PROJECTION,TIME,QBLOCK_NAME,OTHER_XML from PLAN_TEMP; commit select count(*) from SQLOBJ$PLAN Check ADDM Jobs – Shows AWR is Working If there are unusable indexes or other problems, ADDM tasks may not have a status of ‘COMPLETED’ This query shows ADDM tasks select owner || '/' || advisor_name as owner_adv , task_id || '/' || task_name as task_id_name , created , (execution_end - execution_start)*86400 as exe_duratn , (execution_end - created) * 86400 as exe_creatn , how_created , status , 'Description: ' || description as task_desc , 'Error Msg : ' || error_message as error_msg from (select t.*, rank() over (order by execution_end desc) rnk from dba_advisor_tasks t) dat where dat.rnk <= 50 and 1 = 1 order by created desc; Check Object Validity and Recompile Select count(*) from dba_objects where status <> 'VALID' @?/rdbms/admin/utlrp.sql
Linux – Oracle – Display Environment Variables Associated to a Process
Find the process id – Example : Oracle Listener
[grid@server01 admin]$ ps -ef|grep -i listen grid 21687 1 0 Apr21 ? 00:20:28 /oracle/grid/12.2/bin/tnslsnr LISTENER_SCAN1 -no_crs_notify -inherit grid 21938 1 0 Apr21 ? 00:32:52 /oracle/grid/12.2/bin/tnslsnr LISTENER -no_crs_notify -inherit root 31840 31805 0 Apr21 ? 00:00:00 hald-addon-input: Listening on /dev/input/event3 /dev/input/event0 /dev/input/event1 68 32017 31805 0 Apr21 ? 00:00:00 hald-addon-acpi: listening on acpid socket /var/run/acpid.socket grid 32608 13797 0 14:21 pts/5 00:00:00 grep -i listen
Display the Environment Variables
[grid@server01 admin]$ strings /proc/21938/environ __CRS_ACTIVE_VERSION=12.2.0.1.0 __CLSAGFW_TYPE_NAME=ora.mgmtlsnr.type CHECK_WRAP_TRACE=/oracle/gridbase/crsdata/debug/oraagent_trace_needed.txt ORA_CRS_HOME=/oracle/grid/12.2 TERM=linux __CRSD_CONNECT_STR=(ADDRESS=(PROTOCOL=IPC)(KEY=CRSD_IPC_SOCKET_11)) NLS_LANG=AMERICAN_AMERICA.AL32UTF8 CRF_HOME=/oracle/grid/12.2 GIPCD_PASSTHROUGH=false ENVCMD=/bin/env __CRSD_AGENT_NAME=/oracle/grid/12.2/bin/oraagent_grid _ORA_AGENT_ACTION=TRUE __CRSD_MSG_FRAME_VERSION=2 LD_LIBRARY_PATH=/oracle/grid/12.2/lib:/etc/ORCLcluster/lib WRAP_ENVFILE=/oracle/gridbase/crsdata/debug/oraagent_env_20066.log START_MODE= FILEOWNER= __CLSAGENT_INCARNATION=2 CRS_LIMIT_MEMLOCK=unlimited FILEOWNER_ID= __CRS_START_MODE=normal ORACLE_BASE=/oracle/gbase .......