Friday, November 22, 2024

Sunday, November 17, 2024

Imp scripts

 Below SQL to alert us 10 days before for PSAPPS password is about to expire.


select OPRID,LASTPSWDCHANGE from sysadm.psoprdefn where oprid='PSAPPS' and sysdate-LASTPSWDCHANGE>=80;



To Find the PeopleSoft concurrent users:


SELECT OPRID, (to_char (LOGINDTTM, 'yyyy-mm-dd hh24:mi:ss.ff3')) AS  "LOGINDTTM",

to_char(LOGINDTTM, 'D') as DAY

FROM PSACCESSLOG

WHERE OPRID NOT IN ('PSADMIN', 'PRCS', 'PSLDAP', 'PUBUSER', 'RUNCONTROLHR', 'RUNCONTROLTIMS', 'RUNCONTROLPAT', 'RUNCONTROLSEC')

AND LOGINDTTM >'18-JUL-19' AND LOGINDTTM <'19-JUL-19'

AND LOGIPADDRESS !='UNKNOWN'

ORDER BY LOGINDTTM ASC;


Database Size :


SQL> select round((sum(bytes)/1048576/1024),2) from v$datafile;



Tablespace Utilization :


#####################################################################################

## CHECK TABLESPACE SIZE  ##

####################################################################################

#!/bin/ksh

sqlplus -s <<!

oracle/$1@$2

set feed off

set linesize 100

set pagesize 200

spool tablespace.alert

SELECT F.TABLESPACE_NAME,

       TO_CHAR ((T.TOTAL_SPACE - F.FREE_SPACE),'999,999') "USED (MB)",

       TO_CHAR (F.FREE_SPACE, '999,999') "FREE (MB)",

       TO_CHAR (T.TOTAL_SPACE, '999,999') "TOTAL (MB)",

       TO_CHAR ((ROUND ((F.FREE_SPACE/T.TOTAL_SPACE)*100)),'999')||' %' PER_FREE

FROM   (

       SELECT       TABLESPACE_NAME, 

                    ROUND (SUM (BLOCKS*(SELECT VALUE/1024

                                        FROM V\$PARAMETER 

                                        WHERE NAME = 'db_block_size')/1024)

                           ) FREE_SPACE

       FROM DBA_FREE_SPACE

       GROUP BY TABLESPACE_NAMEa

       ) F,

       (

       SELECT TABLESPACE_NAME,

       ROUND (SUM (BYTES/1048576)) TOTAL_SPACE

       FROM DBA_DATA_FILES

       GROUP BY TABLESPACE_NAMEa

       ) T

WHERE F.TABLESPACE_NAME = T.TABLESPACE_NAME

AND (ROUND ((F.FREE_SPACE/T.TOTAL_SPACE)*100)) < 10;

spool off

exit

!

if [ `cat tablespace.alert|wc -l` -gt 0 ]

then

          cat tablespace.alert -l tablespace.alert > tablespace.tmp

          mailx -s "TABLESPACE ALERT for ${2}" PBhaskaran@xfg.com < tablespace.tmp

fi

===================================================================


Script to create the synonyms :


-- Run Dynamic SQL to create synonym script
SET HEA OFF;
SET PAGESIZE 0;
SET LINES 150;
SPOOL SYNONYM.SQL
select 'create public synonym '||object_name||' for '||owner||'.'||object_name||';'
from sys.dba_objects where owner = 'SYSADM' and object_type in ('TABLE', 'VIEW');
SPOOL OFF;

-- Run Dynamic SQL to create grant scripts
SET HEA OFF;
SET PAGESIZE 0;
SET LINES 150
SPOOL GRANT.SQL
select 'grant select, update, insert, delete on '||object_name||' to VOLT_SUID;'
from sys.dba_objects where owner = 'SYSADM' and object_type in ('TABLE', 'VIEW');
SPOOL OFF;

prompt
prompt Manually run synonym script 
prompt Enable spool to generate log
prompt @SYNONYM.SQL
prompt
prompt Manually run grant scripts
prompt Enable spool to generate log
prompt @GRANT.SQL



Kill PSQUERY Automatically after 60mints

 The SELECT below is being run for PSQUERY kill job


SELECT

        'alter system kill session '''  ||sid  ||','  ||serial#  ||', @'  ||inst_id  ||''';'

FROM gv$session a

WHERE a.process IN

  (SELECT ltrim(TO_CHAR(q.sessionidnum))

   FROM psprcsque q,

        psprcsrqst t

  WHERE q.prcsinstance=t.prcsinstance

  AND t.prcsname      ='PSQUERY'

  AND q.rqstdttm      =

    (SELECT DISTINCT MAX(rqstdttm)

      FROM psprcsque q1

      WHERE q1.sessionidnum=q.sessionidnum

    )

  AND t.runstatus IN (7,14,16)

  )

and a.last_call_et > 3600

Percentage of process completed

 


SELECT s.SID,

s.serial#,

s.machine,

ROUND(sl.elapsed_seconds/60) || ':' ||

MOD(sl.elapsed_seconds,60) elapsed,

ROUND(sl.time_remaining/60) || ':' ||

MOD(sl.time_remaining,60) remaining,

ROUND(sl.sofar/sl.totalwork*100, 2) progress_pct

FROM v$session s,

v$session_longops sl

WHERE s.SID = sl.SID

AND s.serial# = sl.serial#

ORDER BY 4 DESC;   

Check tablespace size

 

#####################################################################################

## CHECK TABLESPACE SIZE  ##

####################################################################################

#!/bin/ksh

sqlplus -s <<!

oracle/$1@$2

set feed off

set linesize 100

set pagesize 200

spool tablespace.alert

SELECT F.TABLESPACE_NAME,

       TO_CHAR ((T.TOTAL_SPACE - F.FREE_SPACE),'999,999') "USED (MB)",

       TO_CHAR (F.FREE_SPACE, '999,999') "FREE (MB)",

       TO_CHAR (T.TOTAL_SPACE, '999,999') "TOTAL (MB)",

       TO_CHAR ((ROUND ((F.FREE_SPACE/T.TOTAL_SPACE)*100)),'999')||' %' PER_FREE

FROM   (

       SELECT       TABLESPACE_NAME, 

                    ROUND (SUM (BLOCKS*(SELECT VALUE/1024

                                        FROM V\$PARAMETER 

                                        WHERE NAME = 'db_block_size')/1024)

                           ) FREE_SPACE

       FROM DBA_FREE_SPACE

       GROUP BY TABLESPACE_NAME

       ) F,

       (

       SELECT TABLESPACE_NAME,

       ROUND (SUM (BYTES/1048576)) TOTAL_SPACE

       FROM DBA_DATA_FILES

       GROUP BY TABLESPACE_NAMEa

       ) T

WHERE F.TABLESPACE_NAME = T.TABLESPACE_NAME

AND (ROUND ((F.FREE_SPACE/T.TOTAL_SPACE)*100)) < 10;

spool off

exit

!

if [ `cat tablespace.alert|wc -l` -gt 0 ]

then

          cat tablespace.alert -l tablespace.alert > tablespace.tmp

          mailx -s "TABLESPACE ALERT for ${2}" PBhaskaran@volt.com < tablespace.tmp

fi


Find the Tax upgrade status

 SYS@HCM92DMO>SELECT * FROM SYSADM.PSPROJECTITEM WHERE PROJECTNAME LIKE 'TAX_UPDATE_18A%';


no rows selected


SYS@HCM92DMO>SELECT * FROM sysadm.PS_TAX_UPDATE ORDER BY DT_ENTERED DESC;


Sunday, September 15, 2024

Find HWM and Tunning

 Action Plan :

============


Kill session 


select owner,table_name,num_rows,blocks from dba_tables where table_name='PS_CA_BI_PC_TA14';


result 0 and blocks above xxxx then have issue 


alter table sysadm.PS_CA_BI_PC_TA14 enable row movement;

alter table sysadm.PS_CA_BI_PC_TA14 shrink space;

alter table sysadm.PS_CA_BI_PC_TA14 DISABLE row movement;


alter index sysadm.PSVIZCA_BI_PC_TA14 rebuild online;

alter index sysadm.PS_CA_BI_PC_TA14 rebuild online;


exec DBMS_STATS.GATHER_TABLE_STATS (ownname=> 'SYSADM', tabname=>'PS_CA_BI_PC_TA14', estimate_percent=>100, method_opt=> 'FOR ALL COLUMNS SIZE 254', DEGREE=> 8, cascade=>TRUE);