Search This Blog

Total Pageviews

Thursday, 24 August 2023

OPW-00010: Could not create the password file. This resource has a Password File.

OPW-00010: Could not create the password file. This resource has a Password File.






orapwd file='+DATA/orapwibrac' ENTRIES=10 DBUNIQUENAME=ibrac

Enter password for SYS:

OPW-00010: Could not create the password file. This resource has a Password File.

[grid@irac01 ~]$



srvctl config database -d ibrac
Database unique name: ibrac
Database name:
Oracle home: /u01/app/oracle/product/12.2.0/dbhome_1
Oracle user: oracle
Spfile: +data/IBRAC/PARAMETERFILE/spfile.4018.1145682969  --- as password file already in  this config 
Password file:
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools:
Disk Groups: DATA
Mount point paths:
Services:
Type: RAC
Start concurrency:
Stop concurrency:
OSDBA group: oinstall
OSOPER group: oinstall
Database instances: ibrac1,ibrac2
Configured nodes: ibrac01,ibrac02
CSS critical: no
CPU count: 0
Memory target: 0
Maximum memory: 0
Default network number for database services:
Database is administrator managed
[oracle@ibrac01:~] $


                                  
modify without password file 
srvctl modify database -d ibrac -pwfile



[oracle@irac01:~] $srvctl config database -d ibrac
Database unique name: ibrac
Database name:
Oracle home: /u01/app/oracle/product/12.2.0/dbhome_1
Oracle user: oracle
Spfile: +data/IBRAC/PARAMETERFILE/spfile.4018.1145682969
Password file:                                             <<<<<<< now no password file !!!
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools:
Disk Groups: DATA
Mount point paths:
Services:
Type: RAC
Start concurrency:
Stop concurrency:
OSDBA group: oinstall
OSOPER group: oinstall
Database instances: ibrac1,ibrac2
Configured nodes: ibrac01,ibrac02
CSS critical: no
CPU count: 0
Memory target: 0
Maximum memory: 0
Default network number for database services:
Database is administrator managed



run again!!!

orapwd file='+DATA/orapwibrac' ENTRIES=10 DBUNIQUENAME=ibrac

Enter password for SYS:


ASMCMD [+] > ls -l +DATA/IBRAC/PASSWORD/
Type      Redund  Striped  Time             Sys  Name
PASSWORD  UNPROT  COARSE   AUG 24 08:00:00  Y    pwdibrac.4019.1145693377
ASMCMD [+] >


srvctl modify database -d ibrac -pwfile +DATA/IBRAC/PASSWORD/pwdibrac.4019.1145693377



SQL> alter user sys identified by sys ;  <<< change the password again :)

User altered.

SQL>



Wednesday, 23 August 2023

tfactl – Diagnostic data Collection for troubleshooting the issue of GI, ASM, and RAC

 tfactl – Diagnostic data Collection for troubleshooting the issue of GI, ASM, and RAC



locate file 

locate tfactl
/u01/app/19.0.0/grid/bin/tfactl
/u01/app/19.0.0/grid/suptools/tfa/release/tfa_home/bin/tfactl
/u01/app/19.0.0/grid/suptools/tfa/release/tfa_home/bin/tfactl.bat.tmpl
/u01/app/19.0.0/grid/suptools/tfa/release/tfa_home/bin/tfactl.pl
/u01/app/19.0.0/grid/suptools/tfa/release/tfa_home/bin/tfactl.tmpl





GI_HOME/tfa/bin/tfactl diagcollect -from "MMM/dd/yyyy hh:mm:ss" -to "MMM/dd/yyyy hh:mm:ss"

/u01/app/19.0.0/grid/bin/tfactl diagcollect -from "Aug/23/2023 07:00:00" -to "Aug/23/2023 08:00:00"



 /u01/app/19.0.0/grid/bin/tfactl diagcollect -from "Aug/23/2023 07:00:00" -to "Aug/23/2023 08:00:00"
WARNING - TFA Software is older than 180 days. Please consider upgrading TFA to the latest version.
Collecting data for all nodes
Scanning files from Aug/23/2023 07:00:00 to Aug/23/2023 08:00:00

Collection Id : 20230823083407ibrac01

Detailed Logging at : /u01/app/grid/tfa/repository/collection_Wed_Aug_23_08_34_08_EDT_2023_node_all/diagcollect_20230823083407_ibrac01.log
2023/08/23 08:34:12 EDT : NOTE : Any file or directory name containing the string .com will be renamed to replace .com with dotcom
2023/08/23 08:34:12 EDT : Collection Name : tfa_Wed_Aug_23_08_34_08_EDT_2023.zip
2023/08/23 08:34:12 EDT : Collecting diagnostics from hosts : [ibrac02, ibrac01]
2023/08/23 08:34:12 EDT : Scanning of files for Collection in progress...
2023/08/23 08:34:12 EDT : Collecting additional diagnostic information...
2023/08/23 08:36:07 EDT : Getting list of files satisfying time range [08/23/2023 07:00:00 EDT, 08/23/2023 08:00:00 EDT]
2023/08/23 08:37:20 EDT : Completed collection of additional diagnostic information...
2023/08/23 08:39:53 EDT : Collecting ADR incident files...
2023/08/23 08:39:53 EDT : Completed Local Collection
2023/08/23 08:39:53 EDT : Remote Collection in Progress...
.-------------------------------------------------------------------.
|                         Collection Summary                        |
+---------+------------------------------------------+-------+------+
| Host    | Status                                   | Size  | Time |
+---------+------------------------------------------+-------+------+
| irac02  | Failed Unable to connect to Node ibrac02 |       |      |
| irac01  | Completed                                | 191MB | 341s |
'---------+------------------------------------------+-------+------'

Logs are being collected to: /u01/app/grid/tfa/repository/collection_Wed_Aug_23_08_34_08_EDT_2023_node_all
/u01/app/grid/tfa/repository/collection_Wed_Aug_23_08_34_08_EDT_2023_node_all/irac01.tfa_Wed_Aug_23_08_34_08_EDT_2023.zip

Tuesday, 22 August 2023

ORA-17627: ORA-12543: TNS:destination host unreachable ORA-17629: Cannot connect to the remote database server





[oracle@oracentd19c admin]$ rman target sys/sys@orclprim auxiliary sys/sys@orcldstdy|tee stdy.txt

Recovery Manager: Release 19.0.0.0.0 - Production on Tue Aug 22 06:13:15 2023
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL (DBID=1672814384)
connected to auxiliary database: ORCLS (not mounted)

RMAN> duplicate target database for standby from active database nofilenamecheck;

Starting Duplicate Db at 22-08-2023 06:13:21
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=36 device type=DISK

contents of Memory Script:
{
   backup as copy reuse
   passwordfile auxiliary format  '/u01/app/oracle/product/19c/db_1/dbs/orapworcls'   ;
}
executing Memory Script

Starting backup at 22-08-2023 06:13:22
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=73 device type=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 08/22/2023 06:13:23
RMAN-05501: aborting duplication of target database
RMAN-03015: error occurred in stored script Memory Script
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 08/22/2023 06:13:23
ORA-17627: ORA-12543: TNS:destination host unreachable
ORA-17629: Cannot connect to the remote database server

RMAN>



from prim to standby 

from prod !!!
[oracle@oracent19c admin]$ tnsping orcldstdy

TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 22-AUG-2023 06:14:45

Copyright (c) 1997, 2019, Oracle.  All rights reserved.

Used parameter files:
/u01/app/oracle/product/19c/db_1/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP) (HOST=192.168.0.56)(PORT=1521))(CONNECT_DATA=(SERVER=dedicated)(SID=orcls)))
TNS-12543: TNS:destination host unreachable







Check the firewall !!!!!

on standby 
[root@oracentd19c ~]# firewall-cmd --state
running
[root@oracentd19c ~]# systemctl stop firewalld     or add rule for 1521 
[root@oracentd19c ~]# firewall-cmd --state
not running
[root@oracentd19c ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@oracentd19c ~]# firewall-cmd --state
not running


from prim now working !!
[oracle@oracent19c ~]$ tnsping orcldstdy

TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 22-AUG-2023 06:18:44

Copyright (c) 1997, 2019, Oracle.  All rights reserved.

Used parameter files:
/u01/app/oracle/product/19c/db_1/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP) (HOST=192.168.0.56)(PORT=1521))(CONNECT_DATA=(SERVER=dedicated)(SID=orcls)))
OK (20 msec)
[oracle@oracent19c ~]$



Sunday, 20 August 2023

RMAN-06136: Oracle error from auxiliary database: ORA-17629: Cannot connect to the remote database server ORA-17627: ORA-01017: invalid username/password; logon denied









RMAN-03015: error occurred in stored script Memory Script
RMAN-06136: Oracle error from auxiliary database: ORA-17629: Cannot connect to the remote database server
ORA-17627: ORA-01017: invalid username/password; logon denied




RMAN> duplicate target database to 'orcld' from active database nofilenamecheck;

Starting Duplicate Db at 20-AUG-23
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=38 device type=DISK

contents of Memory Script:
{
   sql clone "create spfile from memory";
}
executing Memory Script

sql statement: create spfile from memory

contents of Memory Script:
{
   shutdown clone immediate;
   startup clone nomount;
}
executing Memory Script

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area    6710885896 bytes

Fixed Size                     9149960 bytes
Variable Size               1174405120 bytes
Database Buffers            5519704064 bytes
Redo Buffers                   7626752 bytes

contents of Memory Script:
{
   sql clone "alter system set  db_name =
 ''ORCL'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   sql clone "alter system set  db_unique_name =
 ''orcld'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   restore clone from service  'orcl3' primary controlfile;
   alter clone database mount;
}
executing Memory Script

sql statement: alter system set  db_name =  ''ORCL'' comment= ''Modified by RMAN duplicate'' scope=spfile

sql statement: alter system set  db_unique_name =  ''orcld'' comment= ''Modified by RMAN duplicate'' scope=spfile

Oracle instance shut down

Oracle instance started

Total System Global Area    6710885896 bytes

Fixed Size                     9149960 bytes
Variable Size               1174405120 bytes
Database Buffers            5519704064 bytes
Redo Buffers                   7626752 bytes

Starting restore at 20-AUG-23
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=35 device type=DISK

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 08/20/2023 19:58:01
RMAN-05501: aborting duplication of target database
RMAN-03015: error occurred in stored script Memory Script
RMAN-06136: Oracle error from auxiliary database: ORA-17629: Cannot connect to the remote database server
ORA-17627: ORA-01017: invalid username/password; logon denied
ORA-17629: Cannot connect to the remote database server


**************************************************************

check the password file name  !!!!

[oracle@oracentd19c dbs]$ ps -ef|grep -i smon
oracle   19234     1  0 20:21 ?        00:00:00 ora_smon_orcld


cp orapworcl orapworcld


Monday, 14 August 2023

Create Pluggable Database(PDB) in Oracle 12c


Create Pluggable Database(PDB) in Oracle 12c
 .. 


Create Pluggable Database(PDB) in Oracle 12c



if required!!!
alter system set "_exclude_seed_cdb_view"=FALSE scope=both;

System altered.





select  distinct substr(name, 1, instr(name, '/',-1)) PATH 
                       from  (
                       select name  from v$datafile
                       union all
                       select NAME  from v$controlfile
                       union all
                       select MEMBER  name from v$logfile
                       union all
                       select name from v$tempfile
) order by 1;                   



take seed database file path 

set linesize 400
col datafile_name for a90
col container for a20
select hxfil file#, d.name datafile_name , c.name container, fhsta fh_status, fhscn fh_scn, fhrba_seq fh_seq , fhafs fh_abs from x$kcvfh x, v$datafile d, v$containers c
where d.file# = x.hxfil
and d.con_id = c.con_id
and c.name='PDB$SEED'
order by c.name,fhscn;

     FILE# DATAFILE_NAME                                                                              CONTAINER             FH_STATUS FH_SCN                   FH_SEQ FH_ABS
---------- ------------------------------------------------------------------------------------------ -------------------- ---------- -------------------- ---------- --------------------
        14 +DATA/VIHCDBD8/ABBFB3354CCC218FE05324F56A40A88A/DATAFILE/system.359.1133670139             PDB$SEED                  40960 52755005                   2043 0
        15 +DATA/VIHCDBD8/ABBFB3354CCC218FE05324F56A40A88A/DATAFILE/sysaux.1322.1133670139            PDB$SEED                  32768 52755005                   2043 0
        20 +DATA/VIHCDBD8/ABBFB3354CCC218FE05324F56A40A88A/DATAFILE/pdb9_undotbs.4153.1133670139      PDB$SEED                  32768 52755005                   2043 0
        17 +DATA/VIHCDBD8/ABBFB3354CCC218FE05324F56A40A88A/DATAFILE/users.1419.1133670139             PDB$SEED                  32768 52755005                   2043 0
        16 +DATA/VIHCDBD8/ABBFB3354CCC218FE05324F56A40A88A/DATAFILE/undotbs1.1320.1133670139          PDB$SEED                  32768 52755005                   2043 0



for temp file alter session set container=PDB$SEED ;

 select NAME from  V$TEMPFILE;

NAME
------------------------------------------------------------------------------------------
+DATA/VIHCDBD8/ABBFB3354CCC218FE05324F56A40A88A/TEMPFILE/temp.4195.1133671127






ww
create pluggable database anujy admin user vihaan identified by vihaan123
default tablespace anujy datafile '+DATA' size 250m autoextend on
file_name_convert=('+DATA/VIHCDBD8/ABBFB3354CCC218FE05324F56A40A88A/DATAFILE/','+DATA','+DATA/VIHCDBD8/ABBFB3354CCC218FE05324F56A40A88A/TEMPFILE/temp.4195.1133671127','+DATA');

Pluggable database created.


create pluggable database anujz admin user vihaan identified by vihaan123
default tablespace anujy datafile '+DATA' size 250m autoextend on
file_name_convert=('+DATA/VIHCDBD8/ABBFB3354CCC218FE05324F56A40A88A/DATAFILE/','+DATA','+DATA/VIHCDBD8/ABBFB3354CCC218FE05324F56A40A88A/TEMPFILE/temp.4195.1133671127','+DATA');
Pluggable database created.




Saturday, 12 August 2023

TOP SQL reporting

TOP SQL reporting





TOP SQL reporting

---- mon_topsql.sql 


https://github.com/vishaldesai/Oracle_Scripts/blob/master/Exadata/mon_topsql.sql

-- Author:      Tanel Poder ( http://blog.tanelpoder.com | tanel@tanelpoder.com )





SET LINES 999 PAGES 5000 TRIMSPOOL ON TRIMOUT ON TAB OFF 

COL pct FOR A10 JUST RIGHT
COL cpu_pct FOR 999.9
COL io_pct FOR 999.9
col OWNER for a20
col OBJECT_NAME    for a20                                                                                                                   
col PROCEDURE_NAME for a20 

BREAK ON day SKIP 1

DEF days=1

PROMPT Displaying daily top SQL for last &days days...

WITH ash AS (
    SELECT 
        day
      , owner
      , object_name
      , procedure_name
      , sql_id
      , sql_plan_hash_value
      , total_seconds
      , io_seconds
      , cpu_seconds
      , LPAD(TRIM(TO_CHAR(RATIO_TO_REPORT(total_seconds) OVER (PARTITION BY day) * 100, '999.9'))||'%', 10) pct
      , RATIO_TO_REPORT(total_seconds) OVER (PARTITION BY day) * 100 pct_num
    FROM (
        SELECT
            TO_CHAR(sample_time, 'YYYY-MM-DD') day
          , sql_id
          , sql_plan_hash_value 
          , p.owner
          , p.object_name
          , p.procedure_name
          , SUM(10) total_seconds
          , SUM(CASE WHEN wait_class = 'User I/O' THEN 10 ELSE 0 END) io_seconds
          , SUM(CASE WHEN wait_class IS NULL THEN 10 ELSE 0 END) cpu_seconds
        FROM
            dba_hist_active_sess_history a
          , dba_procedures p
        WHERE
            a.plsql_entry_object_id = p.object_id (+)
        AND a.plsql_entry_subprogram_id = p.subprogram_id (+)
        AND sample_time > SYSDATE - &days
        AND session_type != 'BACKGROUND' -- ignore for now
        GROUP BY
            sql_id
          , sql_plan_hash_value 
          , p.owner
          , p.object_name
          , p.procedure_name
          , TO_CHAR(sample_time, 'YYYY-MM-DD')
    )
)
, sqlstat AS (
    SELECT /*+ MATERIALIZE */ 
        TO_CHAR(begin_interval_time, 'YYYY-MM-DD') day
      , sql_id
      , plan_hash_value
      , SUM(executions_delta) executions
      , SUM(rows_processed_delta) rows_processed
      , SUM(disk_reads_delta) blocks_read
      , SUM(disk_reads_delta)*8/1024 mb_read
      , SUM(buffer_gets_delta) buffer_gets
      , SUM(iowait_delta)/1000000 awr_iowait_seconds
      , SUM(cpu_time_delta)/1000000 awr_cpu_seconds 
      , SUM(elapsed_time_delta)/1000000 awr_elapsed_seconds
    FROM
        dba_hist_snapshot
      NATURAL JOIN
        dba_hist_sqlstat
    WHERE
        begin_interval_time > SYSDATE - &days
    GROUP BY
        TO_CHAR(begin_interval_time, 'YYYY-MM-DD') 
      , sql_id
      , plan_hash_value
)
SELECT /*+ MONITOR */
        day
      , pct
      , owner
      , object_name
      , procedure_name
      , sql_id
      , sql_plan_hash_value plan_hash
      , ROUND(total_seconds / 3600,1) total_hours
      , total_seconds
      , executions
      , ROUND(total_seconds / NULLIF(executions,0),2) seconds_per_exec
      , io_pct
      , cpu_pct
      , mb_read
      , ROUND(mb_read / NULLIF(executions,0),2) mb_per_exec
      , buffer_gets
      , ROUND(buffer_gets / NULLIF(executions,0),2) bufget_per_exec
      , CASE WHEN sql_id IS NOT NULL THEN 
            'SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_AWR('''||sql_id||''','||CASE WHEN sql_plan_hash_value = 0 THEN 'NULL' ELSE TO_CHAR(sql_plan_hash_value) END||', format=>''ADVANCED''));'
        END extract_plan_from_awr
FROM (
    SELECT
        day
      , pct
      , owner
      , object_name
      , procedure_name
      , sql_id
      , sql_plan_hash_value
      , total_seconds
      , io_seconds/total_seconds*100 io_pct
      , cpu_seconds/total_seconds*100 cpu_pct
      , (SELECT executions FROM sqlstat s  WHERE ash.sql_id = s.sql_id AND ash.sql_plan_hash_value = s.plan_hash_value AND ash.day = s.day) executions
      , (SELECT mb_read FROM sqlstat s     WHERE ash.sql_id = s.sql_id AND ash.sql_plan_hash_value = s.plan_hash_value AND ash.day = s.day) mb_read
      , (SELECT buffer_gets FROM sqlstat s WHERE ash.sql_id = s.sql_id AND ash.sql_plan_hash_value = s.plan_hash_value AND ash.day = s.day) buffer_gets
    FROM 
        ash
    WHERE 
        ash.pct_num >= 1
)
ORDER BY
    day DESC
  , total_seconds DESC
/




DAY               PCT OWNER                OBJECT_NAME          PROCEDURE_NAME       SQL_ID         PLAN_HASH TOTAL_HOURS TOTAL_SECONDS EXECUTIONS SECONDS_PER_EXEC IO_PCT CPU_PCT    MB_READ MB_PER_EXEC BUFFER_GETS BUFGET_PER_EXEC EXTRACT_PLAN_FROM_AWR
---------- ---------- -------------------- -------------------- -------------------- ------------- ---------- ----------- ------------- ---------- ---------------- ------ ------- ---------- ----------- ----------- --------------- --------------------------------------------------------------------------------------------------------------------------
2023-08-12      78.6%                                                                ctyc1af1abg5u  200298931          91        327510                                 .0   100.0                                                    SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_AWR('ctyc1af1abg5u',200298931, format=>'ADVANCED'));
                 4.4%                                                                                       0         5.1         18340                               22.3    72.7
                 4.2%                                                                3xjw1ncw5vh27 2487977020         4.9         17500                               88.3    11.7                                                    SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_AWR('3xjw1ncw5vh27',2487977020, format=>'ADVANCED'));
                 4.2%                                                                c7ngymcfjtb1c 1658157256         4.8         17450                               43.8    56.2                                                    SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_AWR('c7ngymcfjtb1c',1658157256, format=>'ADVANCED'));

2023-08-11      55.1%                                                                ctyc1af1abg5u  200298931        55.9        201130                                 .0   100.0                                                    SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_AWR('ctyc1af1abg5u',200298931, format=>'ADVANCED'));




                 8.7%                                                                1zuyhdtsmmx5s 3008400300         8.8         31680    





define sql_id='ctyc1af1abg5u'

SET TERMOUT OFF pagesize 5000 tab off verify off linesize 999 trimspool on trimout on null ""
SET TERMOUT ON


COL exec_per_sec    FOR 99999990
COL ela_ms_per_sec  FOR 99999990
COL rows_per_sec    FOR 99999990
COL lios_per_sec    FOR 99999990
COL blkrd_per_sec   FOR 99999990
COL cpu_ms_per_sec  FOR 99999990
COL iow_ms_per_sec  FOR 99999990
COL clw_ms_per_sec  FOR 99999990
COL apw_ms_per_sec  FOR 99999990
COL ccw_ms_per_sec  FOR 99999990


SELECT
    CAST(begin_interval_time AS DATE) begin_interval_time
,st.con_id
  , sql_id
  , plan_hash_value
  , ROUND(SUM(executions_delta    )        / ((CAST(end_interval_time AS DATE) - CAST(begin_interval_time AS DATE)) * 86400), 1) exec_per_sec
  , ROUND(SUM(elapsed_time_delta  ) / 1000 / ((CAST(end_interval_time AS DATE) - CAST(begin_interval_time AS DATE)) * 86400), 1) ela_ms_per_sec
  , ROUND(SUM(rows_processed_delta)        / ((CAST(end_interval_time AS DATE) - CAST(begin_interval_time AS DATE)) * 86400), 1) rows_per_sec
  , ROUND(SUM(buffer_gets_delta   )        / ((CAST(end_interval_time AS DATE) - CAST(begin_interval_time AS DATE)) * 86400), 1) lios_per_sec
  , ROUND(SUM(disk_reads_delta    )        / ((CAST(end_interval_time AS DATE) - CAST(begin_interval_time AS DATE)) * 86400), 1) blkrd_per_sec
  , ROUND(SUM(cpu_time_delta      ) / 1000 / ((CAST(end_interval_time AS DATE) - CAST(begin_interval_time AS DATE)) * 86400), 1) cpu_ms_per_sec
  , ROUND(SUM(iowait_delta        ) / 1000 / ((CAST(end_interval_time AS DATE) - CAST(begin_interval_time AS DATE)) * 86400), 1) iow_ms_per_sec
  , ROUND(SUM(clwait_delta        ) / 1000 / ((CAST(end_interval_time AS DATE) - CAST(begin_interval_time AS DATE)) * 86400), 1) clw_ms_per_sec
  , ROUND(SUM(apwait_delta        ) / 1000 / ((CAST(end_interval_time AS DATE) - CAST(begin_interval_time AS DATE)) * 86400), 1) apw_ms_per_sec
  , ROUND(SUM(ccwait_delta        ) / 1000 / ((CAST(end_interval_time AS DATE) - CAST(begin_interval_time AS DATE)) * 86400), 1) ccw_ms_per_sec
FROM
    dba_hist_snapshot sn
  , dba_hist_sqlstat st
WHERE
    sn.snap_id = st.snap_id
AND sn.dbid    = st.dbid
AND sn.instance_number = st.instance_number
AND sql_id = '&sql_id'
--AND plan_hash_value LIKE '2'
--AND begin_interval_time >= 3
--AND end_interval_time   <= 4
-- AND begin_interval_time > sysdate -1
GROUP BY
    CAST(begin_interval_time AS DATE)
,st.con_id
  , CAST(end_interval_time AS DATE)
  , sql_id
  , plan_hash_value
ORDER BY
    begin_interval_time
  , sql_id
  , plan_hash_value
/           



connnect to pdbs

col PLAN_TABLE_OUTPUT for a150
SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_AWR('ctyc1af1abg5u',200298931, format=>'ADVANCED'));




   

Friday, 11 August 2023

-bash: /bin/rm: Argument list too long

-bash: /bin/rm: Argument list too long



rm *.aud -bash: /bin/rm: Argument list too long

Try below command!!!!

find /u01/app/oracle/admin/TROD/adump -name '*.aud' -mtime +5 -delete
find /u01/app/oracle/admin/TROD/adump -name '*.aud'  -delete


find /u01/app/oracle/admin/TROD/adump -name '*.aud' -mtime +5 -exec rm {} \;

Tuesday, 1 August 2023

MAX() KEEP (DENSE_RANK LAST ORDER BY ) OVER() PARTITION BY()


MAX() KEEP (DENSE_RANK LAST ORDER BY ) OVER() PARTITION BY()

KEEP DENSE_RANK

-- Create table CREATE TABLE test (name, sal, deptno) AS SELECT 'a', 1, 1 FROM DUAL UNION ALL SELECT 'b', 1, 1 FROM DUAL UNION ALL SELECT 'c', 1, 1 FROM DUAL UNION ALL SELECT 'd', 2, 1 FROM DUAL UNION ALL SELECT 'e', 3, 1 FROM DUAL UNION ALL SELECT 'f', 3, 1 FROM DUAL UNION ALL SELECT 'g', 4, 2 FROM DUAL UNION ALL SELECT 'h', 4, 2 FROM DUAL UNION ALL SELECT 'i', 5, 2 FROM DUAL UNION ALL SELECT 'j', 5, 2 FROM DUAL; select * from test ; N SAL DEPTNO - ---------- ---------- a 1 1 b 1 1 c 1 1 d 2 1 e 3 1 f 3 1 g 4 2 h 4 2 i 5 2 j 5 2 10 rows selected. SQL !! set linesize 300 col min_name_first_sal for a16 col max_name_first_sal for a16 col min_name_last_sa for a16 col max_name_last_sal for a16 col min_name_last_sal for a16 SELECT DISTINCT deptno, MIN(sal) KEEP (DENSE_RANK FIRST ORDER BY sal) OVER (PARTITION BY deptno) AS min_sal_first_sal, MAX(sal) KEEP (DENSE_RANK FIRST ORDER BY sal desc ) OVER (PARTITION BY deptno) AS max_sal_first_sal, MIN(name) KEEP (DENSE_RANK FIRST ORDER BY sal) OVER (PARTITION BY deptno) AS min_name_first_sal, MAX(name) KEEP (DENSE_RANK FIRST ORDER BY sal) OVER (PARTITION BY deptno) AS max_name_first_sal, MIN(name) KEEP (DENSE_RANK LAST ORDER BY sal) OVER (PARTITION BY deptno) AS min_name_last_sal, MAX(name) KEEP (DENSE_RANK LAST ORDER BY sal) OVER (PARTITION BY deptno) AS max_name_last_sal, deptno FROM test; DEPTNO MIN_SAL_FIRST_SAL MAX_SAL_FIRST_SAL MIN_NAME_FIRST_S MAX_NAME_FIRST_S MIN_NAME_LAST_SA MAX_NAME_LAST_SA DEPTNO ---------- ----------------- ----------------- ---------------- ---------------- ---------------- ---------------- ---------- 2 4 5 g h i j 2 1 1 3 a c e f 1 select * from test ; N SAL DEPTNO - ---------- ---------- a 1 1 b 1 1 c 1 1 d 2 1 e 3 1 f 3 1 g 4 2 h 4 2 i 5 2 j 5 2 10 rows selected. col least_salary_person for a18 select o.deptno ,min(o.sal) keep (dense_rank first order by o.sal, o.name) least_salary ,max(o.sal) keep (dense_rank last order by o.sal , o.name ) MAX_salary ,min(o.name) keep (dense_rank first order by o.sal, o.name ) least_salary_person from test o group by o.deptno; DEPTNO LEAST_SALARY MAX_SALARY LEAST_SALARY_PERSO ---------- ------------ ---------- ------------------ 1 1 3 a 2 4 5 g


====
select empno,
       deptno,
       sal,
      dense_rank() over (partition by deptno order by sal) as myrank
from   scott.emp;

SQL> SQL>   2    3    4    5
     EMPNO     DEPTNO        SAL     MYRANK
---------- ---------- ---------- ----------
      7934         10       1300          1
      7782         10       2450          2
      7839         10       5000          3
      7369         20        800          1
      7876         20       1100          2
      7566         20       2975          3
      7788         20       3000          4
      7902         20       3000          4
      7900         30        950          1
      7654         30       1250          2
      7521         30       1250          2
      7844         30       1500          3
      7499         30       1600          4
      7698         30       2850          5

14 rows selected.

SQL> SQL>
select * from (select empno,
       deptno,
       sal,
      dense_rank() over (partition by deptno order by sal ) as myrank
from   scott.emp
)
where 1=1
and MYRANK=4
;
     EMPNO     DEPTNO        SAL     MYRANK
---------- ---------- ---------- ----------
      7788         20       3000          4
      7902         20       3000          4
      7499         30       1600          4

SQL>

Oracle DBA

anuj blog Archive