Blog

Long Running Operations Monitoring ( V$SESSION_LONGOPS ) in Oracle Database

List operations remaining time > 10 minutes :

SQL>select 
           username,sid, opname, target, sofar, totalwork, units, 
           to_char(start_time,'YYYYMMDD-HH24:MI:SS') StartTime, 
           time_remaining, message  
      from 
           V$SESSION_LONGOPS 
      where 
           time_remaining>600;


USERNAME     SID    OPNAME     TARGET     SOFAR   TOTALWORK  UNITS    STARTTIME         TIME_REMAINING MESSAGE

------------ ------ ---------- ---------- ------- ---------- ------- ----------------- -------------- ---------------------------------------------------------
 TETSUSER    5704   Table Scan TETSUSER.TEST  22414  39677      Blocks    20180920-10:55:49        3676  Table Scan:  JAMES.TEST: 22414 out  of 39677 Blocks done

max_dump_file_size in 12c

MAX_DUMP_FILE_SIZE specifies the maximum size of trace files (excluding the alert log).

ModifiableALTER SESSION, ALTER SYSTEM
  • A numeric value for MAX_DUMP_FILE_SIZE specifies the maximum size in operating system blocks.
  • A numeric value followed by a K or M or G suffix specifies the file size in kilobytes, megabytes, or gigabytes.
  • The special value string UNLIMITED means that there is no upper limit on trace file size. Thus, dump files can be as large as the operating system permits.

The trace file can be split into a maximum of 5 segments, and the size of each segment will typically be 1/5th of the trace file limit.

Truncate a Table of Other User

In order to truncate a table of other user, the DROP ANY TABLE system privilege is required. Without granting this powerful privilege, instead, a procedure is created and granted to the user who can truncate other user’s tables.

In this example, user B is able to truncate table TEST of user A without needing “DROP ANY TABLE” system privilege.

1) In schema A, create a procedure called “truncate_tab”:

SQL>show user

USERA

SQL>create or replace procedure truncate_tab (tab_name IN varchar2) 
as 
begin 
   execute immediate 'truncate table '||tab_name ; 
end; 
/

2) Grant execute on procedure truncate_tab to user B:

SQL>show user

USERA

SQL>grant execute on a.truncate_tab to B;

Grant succeeded.

3) Truncate table A.TEST by user A:

SQL>show user

USERB

SQL> exec a.truncate_tab('TEST');

PL/SQL procedure successfully completed.

Gather Fixed Object Stats Hangs on X$DURABLE_SHARDED_SUBS

SYMPTOM

On 12.1.0.2 database, try to gather fixed table statistics with below command, it hangs at object “X$DURABLE_SHARDED_SUBS”.  Also hangs at select couint(*) from X$DURABLE_SHARDED_SUBS.

SQL>EXEC DBMS_STATS.GATHER_FIXED_OBJECTS_STATS ()

SQL>select count(*) from X$DURABLE_SHARDED_SUBS;

CAUSES

It is a bug for this issue, it is supposed to be fixed in 12.2.0.X.

WORKAROUND

Lock the statistics of this fixed table:

SQL>exec dbms_stats.lock_table_stats('SYS','X$DURABLE_SHARDED_SUBS');

How do I change my Oracle user password ?

c:\>
C:\>sqlplus testuser/Password@//ractest-scan.ractest.local:1521/service

SQL*Plus: Release 12.1.0.2.0 Production on Fri Aug 31 11:44:13 2018
Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters and Automatic Storage Management options


SQL> password

Changing password for TESTUSER
Old password:
New password:
Retype new password:
Password changed

SQL>