Script to create new user with existing DB user Privs:

Script to create new user with existing DB user Privs:

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

userdetails_new.sql
===============
set pages 0 feed off veri off lines 500

accept oldname prompt "Enter user to model new user to: "
accept newname prompt "Enter new user name: "
accept new_sch_password prompt "Enter new user password: "
set serveroutput on
spool CREATE_GRANT_SCH_spool.sql

-- Create user...
select 'create user &&newname identified by &&new_sch_password'||''||
       ' default tablespace '||default_tablespace||
      ' temporary tablespace '||temporary_tablespace||' profile '||
       profile||';'
from   sys.dba_users
where  username = upper('&&oldname');

-- Grant Roles...
select 'grant '||granted_role||' to &&newname'||
       decode(ADMIN_OPTION, 'YES', ' WITH ADMIN OPTION')||';'
from   sys.dba_role_privs
where  grantee = upper('&&oldname');

-- Grant System Privs...
select 'grant '||privilege||' to &&newname'||
       decode(ADMIN_OPTION, 'YES', ' WITH ADMIN OPTION')||';'
from   sys.dba_sys_privs
where  grantee = upper('&&oldname');

-- Grant on base user objects...
select 'grant select,insert,update,delete,index on ' || owner ||'."' || OBJECT_NAME || '" to '||upper('&&newname')||' ;' from dba_objects where OBJECT_TYPE in ('TABLE') and owner = upper('&&oldname');

select 'grant select,insert,update,delete on ' || owner ||'."' || OBJECT_NAME || '" to '||upper('&&newname')||' ;' from dba_objects where OBJECT_TYPE in ('VIEW') and owner = upper('&&oldname');

select 'grant select on ' || owner ||'."' || OBJECT_NAME || '" to '||upper('&&newname')||' ;' from dba_objects where OBJECT_TYPE='SEQUENCE' and owner = upper('&&oldname');

select 'grant execute on ' || owner ||'."' || OBJECT_NAME || '" to '||upper('&&newname')||' ;' from dba_objects where OBJECT_TYPE in ('PROCEDURE','FUNCTION','PACKAGE','PACKAGE BODY') and owner = upper('&&oldname');

-- Grant Table Privs...
select 'grant '||privilege||' on '||owner||'."'||table_name||'" to &&newname;'
from   sys.dba_tab_privs
where  grantee = upper('&&oldname');

-- Grant Column Privs...
select 'grant '||privilege||' on '||owner||'."'||table_name||'"('||column_name||') to &&newname;'
from   sys.dba_col_privs
where  grantee = upper('&&oldname');

-- Tablespace Quotas...
select 'alter user &&newname quota '||
       decode(max_bytes, -1, 'UNLIMITED', max_bytes)||
       ' on '||tablespace_name||';'
from   sys.dba_ts_quotas
where  username = upper('&&oldname');

-- Set Default Role...
set serveroutput on
declare
  defroles varchar2(4000);
begin
  for c1 in (select * from sys.dba_role_privs
              where grantee = upper('&&oldname')
                and default_role = 'YES'
  ) loop
      if length(defroles) > 0 then
         defroles := defroles||','||c1.granted_role;
      else
         defroles := defroles||c1.granted_role;
      end if;
  end loop;
  dbms_output.put_line('alter user &&newname default role '||defroles||';');
end;
/
spool off
set pages 1000 feed on veri on lines 500
PROMPT
PROMPT
PROMPT Please Execute : CREATE_GRANT_SCH_spool.sql
PROMPT
PROMPT

gen_synonym_sch_user.sh
===================
echo "Enter Base User Name"
read base_user
echo "Enter new SCH User Name"
read sch_user

${ORACLE_HOME}/bin/sqlplus -s /nolog << SQLEND
conn /as sysdba
set feedback off
set pages 0
set lines 150
set heading off
spool CREATE_SYNONYMS_${ORACLE_SID}_${sch_user}.sql
select 'create SYNONYM ${sch_user}.' || OBJECT_NAME || ' for ' || OWNER||'.'||OBJECT_NAME ||';' from dba_objects where OBJECT_TYPE in ('TABLE','SEQUENCE','PROCEDURE','FUNCTION','VIEW') and owner = upper('${base_user}');
select 'create SYNONYM ${sch_user}.' || SYNONYM_NAME || ' for ' || TABLE_OWNER ||'.'||TABLE_NAME||';' from dba_SYNONYMs where OWNER=upper('${base_user}');
spool off
SQLEND

chmod 777 CREATE_SYNONYMS_${ORACLE_SID}_${sch_user}.sql
echo " "
echo " "
echo "Please Execute : CREATE_SYNONYMS_${ORACLE_SID}_${sch_user}.sql "
echo " "
echo " "

For OTM Users
=============
create user otmgreportdev_sch  identified by  otmgreportdev#12sch;

grant administer database trigger to otmgreportdev_sch;

grant create session to otmgreportdev_sch;

grant create trigger to otmgreportdev_sch;

connect glogowner/glogowner@otmtest

PROMPT
@@../script8/chk_queue_status
DECLARE
CURSOR c_cur IS
                SELECT uo.OBJECT_NAME, DECODE(uo.OBJECT_TYPE,'TABLE',0,'VIEW',1,'SEQUENCE',2,3) "OBJECT_TYPE"
                FROM user_objects uo
                WHERE uo.OBJECT_TYPE IN ('TABLE','PACKAGE','SEQUENCE','FUNCTION','PROCEDURE','VIEW','TYPE')
                and object_name not like 'EUL4%'
      and object_name not like '%$%';

BEGIN
                FOR crec IN c_cur LOOP
                BEGIN
                                -- for tables and views
                                IF crec.OBJECT_TYPE<2 THEN
                                                execute IMMEDIATE 'grant select on '||crec.OBJECT_NAME|| ' to otmgreportdev_sch';
                                                IF crec.OBJECT_TYPE=0 THEN
                                                                execute IMMEDIATE 'grant references on '||crec.OBJECT_NAME|| ' to otmgreportdev_sch';
                                                END IF;

                                END IF;
        EXCEPTION
           WHEN OTHERS THEN
             DBMS_OUTPUT.PUT_LINE(crec.object_name||':   '||SUBSTR(SQLERRM,1,255));
                END;
                END LOOP;
END;
/


grant execute on vpd to otmgreportdev_sch;

grant execute on GLOG_UTIL to otmgreportdev_sch;

Connect reportowner/reportowner@otmtest

PROMPT
@@chk_queue_status
DECLARE
CURSOR c_cur IS
                SELECT uo.OBJECT_NAME, DECODE(uo.OBJECT_TYPE,'TABLE',0,'VIEW',1,'SEQUENCE',2,3) "OBJECT_TYPE"
                FROM user_objects uo
                WHERE uo.OBJECT_TYPE IN ('TABLE','PACKAGE','SEQUENCE','FUNCTION','PROCEDURE','VIEW','TYPE')
                and object_name not like 'EUL4%'
      and object_name not like '%$%';

BEGIN
                FOR crec IN c_cur LOOP
                BEGIN
                                -- for tables and views
                                IF crec.OBJECT_TYPE<2 THEN
                                                execute IMMEDIATE 'grant select on '||crec.OBJECT_NAME|| ' to otmgreportdev_sch';
                                                IF crec.OBJECT_TYPE=0 THEN
                                                                execute IMMEDIATE 'grant references on '||crec.OBJECT_NAME|| ' to otmgreportdev_sch';
                                                END IF;

                                END IF;
        EXCEPTION
           WHEN OTHERS THEN
             DBMS_OUTPUT.PUT_LINE(crec.object_name||':   '||SUBSTR(SQLERRM,1,255));
                END;
                END LOOP;
END;
/

connect otmgreportdev_sch/author_otm@otmtest

CREATE or replace TRIGGER set_vpd_trig AFTER LOGON ON DATABASE
BEGIN
vpd.set_user('DBA.ADMIN');
END;
/

or 

create user otmgreportdev_sch identified by otmgreportdev#12sch

grant administer database trigger to otmgreportdev_sch;

grant create session to otmgreportdev_sch;

grant create trigger to otmgreportdev_sch;

connect glogowner/glogowner@otmtest

PROMPT
@@../script8/chk_queue_status
DECLARE
CURSOR c_cur IS
                SELECT uo.OBJECT_NAME, DECODE(uo.OBJECT_TYPE,'TABLE',0,'VIEW',1,'SEQUENCE',2,3) "OBJECT_TYPE"
                FROM user_objects uo
                WHERE uo.OBJECT_TYPE IN ('TABLE','PACKAGE','SEQUENCE','FUNCTION','PROCEDURE','VIEW','TYPE')
                and object_name not like 'EUL4%'
      and object_name not like '%$%';

BEGIN
                FOR crec IN c_cur LOOP
                BEGIN
                                -- for tables and views
                                IF crec.OBJECT_TYPE<2 THEN
                                                execute IMMEDIATE 'grant select on '||crec.OBJECT_NAME|| ' to otmgreportdev_sch';
                                                IF crec.OBJECT_TYPE=0 THEN
                                                                execute IMMEDIATE 'grant references on '||crec.OBJECT_NAME|| ' to otmgreportdev_sch';
                                                END IF;

                                END IF;
        EXCEPTION
           WHEN OTHERS THEN
             DBMS_OUTPUT.PUT_LINE(crec.object_name||':   '||SUBSTR(SQLERRM,1,255));
                END;
                END LOOP;
END;
/


grant execute on vpd to otmgreportdev_sch;

grant execute on GLOG_UTIL to otmgreportdev_sch;

Connect reportowner/reportowner@otmtest

PROMPT
@@chk_queue_status
DECLARE
CURSOR c_cur IS
                SELECT uo.OBJECT_NAME, DECODE(uo.OBJECT_TYPE,'TABLE',0,'VIEW',1,'SEQUENCE',2,3) "OBJECT_TYPE"
                FROM user_objects uo
                WHERE uo.OBJECT_TYPE IN ('TABLE','PACKAGE','SEQUENCE','FUNCTION','PROCEDURE','VIEW','TYPE')
                and object_name not like 'EUL4%'
      and object_name not like '%$%';

BEGIN
                FOR crec IN c_cur LOOP
                BEGIN
                                -- for tables and views
                                IF crec.OBJECT_TYPE<2 THEN
                                                execute IMMEDIATE 'grant select on '||crec.OBJECT_NAME|| ' to otmgreportdev_sch';
                                                IF crec.OBJECT_TYPE=0 THEN
                                                                execute IMMEDIATE 'grant references on '||crec.OBJECT_NAME|| ' to otmgreportdev_sch';
                                                END IF;

                                END IF;
        EXCEPTION
           WHEN OTHERS THEN
             DBMS_OUTPUT.PUT_LINE(crec.object_name||':   '||SUBSTR(SQLERRM,1,255));
                END;
                END LOOP;
END;
/

connect otmgreportdev_sch/author_otm@otmtest

CREATE or replace TRIGGER set_vpd_trig AFTER LOGON ON DATABASE
BEGIN
vpd.set_user('DBA.ADMIN');
END;
/

Oracle Fusion Middleware components

Oracle Fusion Middleware components:

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

Oracle Fusion Middleware  components

- Oracle WebLogic Server (J2EE Application Server)
- Oracle SOA Suite
- Oracle WebCenter
- Oracle HTTP Server
- Oracle WebCache
- Oracle Internet Directory – OID
- Oracle Virtual Directory – OVD
- Oracle Identity Federation – OIF
- Oracle Web Services Manager – OWSM
- Oracle Platform Security Services – OPSS
- Oracle Portal
- Oracle Business Intelligence Discoverer

Daily Needs for a DBA(Activities)

Daily Needs for a DBA:
================                                     


to fetch the apps pwd from 11.5.10.2
============================


grep -i pass $IAS_CONFIG_HOME/A*/modplsql/cfg/*.app


To kill the hung concurrent requests
==========================


 update fnd_concurrent_requests set status_code='X' , phase_code='C' where request_id='150120296';

To fetch the code from backend
===========================

set pagesize 0
set linesize 200
Set head off
Spool GEWE_IR_SR_APPROVE_PKG.24Jun12.sql
select text from dba_source where NAME like 'GEWE_IR_SR_APPROVE_PKG%'
and type like '%PACKAGE%';
spool off

To generate the RSA and DSA public keys
=============================
inputs will be NONE ..all ENTER

ssh-keygen -t rsa   --to generate RSA public key
/usr/bin/ssh-keygen -t dsa  --to generate DSA public key

Purge the log files
===============
find . -name "*.req" -mtime +15 -exec rm {} \; --to purge 15 days old

Cluster command to check the current clusters from root in solaris
===============================================
/opt/VRTS/bin/hares -state |grep instance name |grep `hostname`|egrep -v 'mount|public|dg|share|nfs|mnt'



/opt/VRTSvcs/bin/hagrp -display instance name| grep -i frozen  --to chk the database cluster status

/opt/VRTSvcs/bin/hagrp -freeze erpshst1 -sys `uname -n`  --to keep in freeze mode


   /opt/VRTS/bin/hares -offline  orpogpp1_app_X -sys `hostname`   --to bring down
    /opt/VRTS/bin/hares -clear  orpogpp1_app_X -sys `hostname`    --to clear if its failed
    /opt/VRTS/bin/hares -online  orpogpp1_app_X -sys `hostname`  --to bring up

To check the printer from backend
==========================
lpstat -a DSALBCGEIDTAG1


set bachspace to remove in solaris
===============================
stty erase ^h


Compiling forms,libraries,reports in Oracle Apps
=====================================

You all are may be well aware that we use f60gen for compiling forms and libraries in Oracle Applications Version 11i,But this is deprecated in R12 and we need to use frmcmp(Form Compiler) To compile forms,menus,PL/SQL libraries.

Compiling library files

11.5.9 and 11.5.10

$ f60gen module=/test/applmgr/11510/au/11.5.0/resource/OEXOELIN.pll userid=apps/passwd
output_file=/test/applmgr/11510/au/11.5.0/resource/OEXOELIN.plx module_type=library
batch=no compile_all=special

R12

$ frmcmp_batch module=/test/applmgr/11510/au/11.5.0/resource/OEXOELIN.pll userid=apps/passwd
output_file=/test/applmgr/11510/au/11.5.0/resource/OEXOELIN.plx module_type=library
batch=no compile_all=special


Compiling forms

11.5.9 and 11.5.10

[applmgr@oracle vis11appl]$export FORMS60_PATH=$FORMS60_PATH:$AU_TOP/fomrs/US
[applmgr@oracle vis11appl]$ echo $FORMS60_PATH
/apps/appl/vis11appl/au/11.5.0/resource:/apps/appl/vis11appl/au/11.5.0/resource/stub:
/apps/appl/vis11appl/au/11.5.0/forms/US
[applmgr@oracle vis11appl]$

f60gen module=$AU_TOP/forms/US/APXSUMBA.fmb userid=apps/appspasswd
output_file=$PROD_TOP/forms/US/APXSUMBA.fmx module_type=form
batch=no compile_all=special

R12

$ frmcmp_batch module=<path to the fmb file> userid=apps/<apps pwd>
output_file=<path to the fmx file> compile_all=special batch=yes

Compiling reports

Syntax

adrepgen userid=APPS/APPS
source=/<full path of schema top>/reports/<report name>.rdf
dest=/<full path of schema top>/reports/<report name>.rdf stype=rdffile
dtype=rdffile logfile=<report name>.log overwrite=yes batch=yes dunit=character

Example

adrepgen userid=apps/appspasswd source=/test/applmgr/11510/ap/11.5.0/reports/US/APXPBBLD.rdf dest=/test/applmgr/11510/admin/TEST/out/tmp001.rdf stype=rdffile dtype=rdffile logfile=/test/applmgr/11510/admin/TEST/out/adrep001.txt overwrite=yes batch=yes compile_all=yes

****what is the diff between batch=yes and no *******

If batch=yes -> it won't display the output,If  batch=no -> it will display output

To Enable trace using running sql sessions
==============================

connect / as sysdba
oradebug setospid 84
oradebug unlimit
oradebug event 10046 trace name context forever,level 12
<wait for some considerable time>
oradebug event 10046 trace name context off

To Check the version of the files
=======================

strings -a ./hxc/11.5.0/patch/115/sql/hxcafnawf.pkb |grep '$Header'
 adident  Header  ./hxc/11.5.0/patch/115/sql/hxcafnawf.pkb


Killing All processes at once:
===============================
Yesterday we come across a situation where we have to kill all look-a-like processes at once, this is what we followed to get rid of it.
kill -9 `ps -ef | grep -i applmgr | grep -i 889 | grep -v grep | awk '{print $2}'`
ps -efw | grep -i applmgr | grep | grep -v grep | awk '{print "kill -9 "$2}'

To avoid the relink set the below memory parameter
=====================================

Relink Issue:

$LDR_CNTRL="MAXDATA=0x40000000"
$export LDR_CNTRL

Move files for 30 days old
=====================
mv `find . -mtime +30` /opt/oracle/apps/common/OICP/inbound/XXATFAQS/processed/archive/   --move files older then 30 days


To verify the Stats
==============

set serveroutput on

exec fnd_stats.verify_stats('APPLSYS','FND_CONCURRENT_REQUESTS');--stats verification


SQL> exec dbms_stats.gather_table_stats ( -
 ownname          => 'INV', -
 tabname          => 'MTL_TRANSACTION_ACCOUNTS' -
)> > >
/


R12 Compile JSP:
==================

$FND_TOP/patch/115/bin

ojspCompile.pl

ojspCompile.pl --compile --fast --quiet

and clear persistence for login issues


Clear directory under persistence from below directory and restart all three OC4J
 rm -rf $ORA_CONFIG_HOME/10.1.3/j2ee/oacore/persistence/*
rm -rf $ORA_CONFIG_HOME/10.1.3/j2ee/oafm/persistence/*
rm -rf $ORA_CONFIG_HOME/10.1.3/j2ee/forms/persistence/*



SQL Profile from backend
=====================
Create  task ..it needs sql id and Name of task
=================================

DECLARE
   my_task_name                  VARCHAR2 (30);
BEGIN
   my_task_name := dbms_sqltune.create_tuning_task (
                      sql_id                        => '7asddw0r2wykx'
                     ,plan_hash_value               => NULL
                     ,SCOPE                         => 'COMPREHENSIVE'
                     ,time_limit                    => 3000
                     ,task_name                     => 'C2CTST_Issue2'
                     ,description                   => NULL);
END;
/
Execute task
==========
exec dbms_sqltune.execute_tuning_task (task_name => 'C2CTST_Issue2');

View the report and analyze
====================
set long 100000
set longchunksize 10000
set linesize 10000
set pages 10000
SELECT dbms_sqltune.report_tuning_task ('C2CTST_Issue1') FROM DUAL;

Output is not feasible then drop using below
================================
exec dbms_sqltune.drop_tuning_task(task_name => 'OPRD_CMchange');





Query to check latest roll ups
===============================

select bug_number Bug, decode(bug_number,3262159, 'Patch 11i.FND.H',
3262919, 'Patch 11i.FWK.H',3126422, '11.5.9 CU1',
3171663, '11.5.9 CU2',
3140000, '11.5.10 Maintenance Pack',
3240000, '11.5.10 Consolidated Update 1 (CU1)',
3640000, '11.5.10.1 Maintenance Pack',
4017300, '11.5.10 Consolidated Update 1 (CU1) for ATG Product Family',
3460000, '11.5.10 Consolidated Update 2 (CU2)',
3480000, '11.5.10.2 Maintenance Pack',
4125550, '11.5.10 Consolidated Update (CU2) for ATG Product Family',
3438354, 'Patch 11i.ATG_PF.H',
4334965, '11i.ATG_PF.H Rollup 3',
4676589, '11i.ATG_PF.H.RUP4',
5473858, '11i.ATG_PF.H.RUP5',
5903765, '11i.ATG_PF.H.RUP6',
6241631, '11i.ATG_PF.H.RUP7') Patch,
b.LAST_UPDATE_DATE Last_update
from AD_BUGS b
where b.BUG_NUMBER in ('3262919','3262159','3126422','3171633','3140000','3240000','3640000','4017300','3460000','3480000','4125550','3438354','4334965','4676589','5473858','5903765','6241631')
order by patch;


User's Responsibilities:
============================

SELECT frt.RESPONSIBILITY_NAME, furg.end_date
FROM
         fnd_user_resp_groups furg,
         FND_RESPONSIBILITY fr,
         fnd_responsibility_tl frt,
         fnd_user fu
WHERE fu.user_name = 'ORAKOUSHIKA'
AND   fu.user_id = furg.user_id
AND   furg.responsibility_id = fr.RESPONSIBILITY_ID
AND   frt.responsibility_id = fr.RESPONSIBILITY_ID
ORDER BY 1;

FIND REDO LOGS INFO:
===================

select a.group#, a.bytes/(1024*1024) mb, a.members, b.member
from v$log a, v$logfile b
where a.group#=b.group#
order by a.group#;


Monitoring Cursors:
===================

select sum(a.value) total_cur, avg(a.value) avg_cur, max(a.value) max_cur,
s.username, s.machine
from v$sesstat a, v$statname b, v$session s
where a.statistic# = b.statistic#  and s.sid=a.sid
and b.name = 'opened cursors current'
group by s.username, s.machine
order by 1 desc;

select a.value, s.username, s.sid, s.serial#
from v$sesstat a, v$statname b, v$session s
where a.statistic# = b.statistic#  and s.sid=a.sid
and b.name = 'opened cursors current';



Querry to check Table-Defragmentation:
=====================================

select owner,table_name,round((blocks*8),2)/(1024) "TABLE SIZE",round((num_rows*avg_row_len/1024),2)/(1024) "ACTUAL DATA" ,  
( round((blocks*8),2) - round((num_rows*avg_row_len/1024),2) )/(1024) "Wasted Space in Table"
from dba_tables
WHERE owner not in (  'SYS' , 'SYSTEM' ) and ( round((blocks*8),2) - round((num_rows*avg_row_len/1024),2) )/(1024) is not null
 order by 5 desc

DROP Issue
==============
SQL> DROP TABLE GEPSMFG.GEPS_LOB_TEMP CASCADE CONSTRAINTS;
SP2-0544: Command "drop" disabled in Product User Profile
SQL> select char_value from product_user_profile where ATTRIBUTE='DROP' and PRODUCT='SQL*Plus';

CHAR_VALUE
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
DISABLED

SQL> update product_user_profile set char_value='ENABLED' where ATTRIBUTE='DROP' and PRODUCT='SQL*Plus';

1 row updated.

SQL> commit;

Commit complete.

SQL>


DB Keep Pool
=============

set pages 999
set lines 92
spool keep_syn.lst
drop table t1;
create table t1 as
select
   o.owner          owner,
   o.object_name    object_name,
   o.subobject_name subobject_name,
   o.object_type    object_type,
   count(distinct file# || block#)         num_blocks
from
   dba_objects  o,
   v$bh         bh
where
   o.data_object_id  = bh.objd
and
   o.owner not in ('SYS','SYSTEM')
and
   bh.status != 'free'
group by
   o.owner,
   o.object_name,
   o.subobject_name,
   o.object_type
order by
   count(distinct file# || block#) desc
;
select
   'alter '||s.segment_type||' '||t1.owner||'.'||s.segment_name||' storage (buffer_pool keep);'
from
   t1,
   dba_segments s
where
   s.segment_name = t1.object_name
and
   s.owner = t1.owner
and
   s.segment_type = t1.object_type
and
   nvl(s.partition_name,'-') = nvl(t1.subobject_name,'-')
and
   buffer_pool <> 'KEEP'
and
   object_type in ('TABLE','INDEX')
group by
   s.segment_type,
   t1.owner,
   s.segment_name
having
   (sum(num_blocks)/greatest(sum(blocks), .001))*100 > 80
;
Stored Outlines:
================
http://www.oracle-base.com/articles/misc/Outlines.php

SELECT SQL_ID,HASH_VALUE FROM V$SQL WHERE SQL_ID='bknbsrc9yaxfq';
SELECT SQL_TEXT FROM V$SQL WHERE HASH_VALUE='333805014';

ALTER SYSTEM SET OPTIMIZER_FEATURES_ENABLE ='9.2.0';

 BEGIN
  DBMS_OUTLN.create_outline(
    hash_value    => 333805014,
    child_number  => 0,
    category      => 'C2C2_OUTLINES2');
END;
/  

SQL> SELECT name, category, sql_text FROM user_outlines WHERE category = 'C2C2_OUTLINES2';

NAME                           CATEGORY                       SQL_TEXT
------------------------------ ------------------------------ --------------------------------------------------------------------------------
SYS_OUTLINE_11071507080129703  C2C2_OUTLINES2                 SELECT v.company_code, v.site_code, v.receiving_number, v.package_number, v.purc


COLUMN hint FORMAT A50
SELECT node, stage, join_pos, hint  FROM user_outline_hints WHERE name = 'SYS_OUTLINE_11071507080129703';

SELECT name, category, used FROM user_outlines where category like '%C2C2%';

 ALTER SYSTEM SET OPTIMIZER_FEATURES_ENABLE ='11.1.0.7';


ALTER system SET query_rewrite_enabled=TRUE;

ALTER system SET use_stored_outlines=C2C2_OUTLINES2;

run the query now

then explain plan for query

then check the outline status

SELECT name, category, used FROM user_outlines where category like '%C2C2%';

Shrink datafile:
================

column cmd format a75 word_wrapped

select 'alter database datafile '||file_name||' resize '||ceil( (nvl(hwm,1)*&&blksize)/1024/1024 )||'m;' cmd
from dba_data_files a, ( select file_id, max(block_id+blocks-1) hwm from dba_extents group by file_id ) b
where a.file_id = b.file_id(+) and ceil( blocks*&&blksize/1024/1024) -ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) > 0

***************ROLES*************
SET TERMOUT OFF
SET NEWPAGE 0
SET SPACE 0
SET LINESIZE 999
SET PAGESIZE 0
SET ECHO OFF
SET FEEDBACK OFF
SET HEADING OFF
spool roles_grant.sql
select 'grant ' ||GRANTED_ROLE || ' to ' ||GRANTEE|| ' with ADMIN OPTION ;'
from dba_role_privs where ADMIN_OPTION='YES' 
UNION
select 'grant ' ||GRANTED_ROLE || ' to ' ||GRANTEE|| ';'
from dba_role_privs where ADMIN_OPTION='NO' ;
SELECT 'EXIT;' FROM DUAL;
SPOOL OFF
SET TERMOUT ON
EXIT;



***************object & sys privs***********

SET TERMOUT OFF
SET NEWPAGE 0
SET SPACE 0
SET LINESIZE 80
SET PAGESIZE 0
SET ECHO OFF
set feedback off
set heading off
spool sys_obj_privs_grant.sql
select 'grant ' || PRIVILEGE || ' to ' || GRANTEE|| ';'from dba_sys_privs
UNION
select 'grant ' ||PRIVILEGE|| ' on ' ||owner || '.'||TABLE_NAME|| ' to ' ||GRANTEE|| ' with grant OPTION ;'
from dba_tab_privs where GRANTABLE='YES' and owner not in (select username from dba_users where username like '%SYS%')
UNION
select 'grant ' ||PRIVILEGE|| ' on ' ||owner || '.'||TABLE_NAME|| ' to ' ||GRANTEE|| ';'
from dba_tab_privs where GRANTABLE='NO' and owner not in (select username from dba_users where username like '%SYS%');
SELECT 'EXIT;' FROM DUAL;
SPOOL OFF
SET TERMOUT ON
EXIT;

WF Sync from backend
=======================
begin apps.wf_local_synch.BULKSYNCHRONIZATION(P_ORIG_SYSTEM=>'ALL',
P_PARALLEL_PROCESSES=>2,
P_LOGGING=>'LOGGING', P_RAISEERRORS=>TRUE,
P_TEMPTABLESPACE=>'APPS_TS_TX_DATA'); END;


Resize datafiles 
=================

set verify off
column file_name format a50 word_wrapped
column smallest format 999,990 heading "Smallest|Size|Poss."
column currsize format 999,990 heading "Current|Size"
column savings  format 999,990 heading "Poss.|Savings"
break on report
compute sum of savings on report
column value new_val blksize
select value from v$parameter where name = 'db_block_size'
/
select file_name,
       ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) smallest,
       ceil( blocks*&&blksize/1024/1024) currsize,
       ceil( blocks*&&blksize/1024/1024) -
       ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) savings
from dba_data_files a,
     ( select file_id, max(block_id+blocks-1) hwm
         from dba_extents
        group by file_id ) b
where a.file_id = b.file_id(+)
/
column cmd format a75 word_wrapped
select 'alter database datafile '''||file_name||''' resize ' ||
       ceil( (nvl(hwm,1)*&&blksize)/1024/1024 )  || 'm;' cmd
from dba_data_files a,
     ( select file_id, max(block_id+blocks-1) hwm
         from dba_extents
        group by file_id ) b
where a.file_id = b.file_id(+)
  and ceil( blocks*&&blksize/1024/1024) -
      ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) > 0 and a.tablespace_name='APPS_TS_TX_DATA'
/

Query to find object growth
==========================

SQL> col object_name for a35
SQL> set pages 0
SQL> set linesize 200
SQL> select * from (select c.TABLESPACE_NAME,c.segment_name "Object Name",b.object_type,
  2  sum(space_used_delta)/1024/1024 "Growth (MB)"
  3  from dba_hist_snapshot sn,
  4  dba_hist_seg_stat a,
  5  dba_objects b,
  6  dba_segments c
  7  where begin_interval_time > trunc(sysdate) - &days_back
  8  and sn.snap_id = a.snap_id
  9  and b.object_id = a.obj#
 10  and b.owner = c.owner
 11  and b.object_name = c.segment_name
 12  and b.object_name = c.segment_name
 13  group by c.TABLESPACE_NAME,c.segment_name,b.object_type)
 14  order by 3 asc;
Enter value for days_back: 30
old   7: where begin_interval_time > trunc(sysdate) - &days_back
new   7: where begin_interval_time > trunc(sysdate) - 30



OPP
====

UPDATE fnd_cp_services
SET developer_parameters =
'J:oracle.apps.fnd.cp.gsf.GSMServiceController:-mx1024m'
WHERE service_id = (SELECT manager_type
FROM fnd_concurrent_queues
WHERE concurrent_queue_name = 'FNDCPOPP');


SSO Issue
===========

select fpot.user_profile_option_name, fpov.profile_option_value,fpov.last_update_date,fu.user_name
from apps.fnd_profile_options fpo, apps.fnd_profile_options_tl fpot, apps.fnd_profile_option_values fpov, apps.fnd_user fu
where fpo.profile_option_id = fpov.profile_option_id
and fpov.level_id=10001
and fpov.last_updated_by=fu.user_id
and fpo.profile_option_name in ('APPS_FRAMEWORK_AGENT','APPS_SSO','APPS_SSO_LDAP_SYNC','APPS_SSO_LOCAL_LOGIN','APPS_SSO_ALLOW_MULTIPLE_ACCOUNTS','APPS_SSO_USER_CREATE_UPDATE','APPS_SSO_LINK_TRUTH_SRC','APPS_SSO_AUTO_LINK_USER','FND_OVERRIDE_SSO_LANG')
and fpo.profile_option_name=fpot.profile_option_name
and fpot.language='US'
order by 1;


select fpot.user_profile_option_name, fpov.profile_option_value,fpov.last_update_date,fu1.user_name
   from apps.fnd_profile_options fpo, apps.fnd_profile_options_tl fpot, apps.fnd_profile_option_values fpov, apps.fnd_user fu,apps.fnd_user fu1
where fpo.profile_option_id = fpov.profile_option_id
   and fpov.level_id=10004
   and fpov.level_value=fu.user_id
   and fpov.last_updated_by=fu1.user_id
   and fpo.profile_option_name=fpot.profile_option_name
   and fpot.language='US'
   and fu.user_name='502064474'
  order by 1;

select user_name,end_date,user_guid from apps.fnd_user where user_name='502078503';


Out of Memory 
==============
SQL> !prtconf | grep Mem
Memory size: 131072 Megabytes

id -p --need to run in oracle user to find the projid
orapgre2@tsgsd5904 $ id -p
uid=502064261(orapgre2) gid=502064270(dbapgre2) projid=1001(user.orapgre2)

login as root
==============
Please managed user's shared memory appropriately. You will have to remove any shared memory in use in order to restart the database, user can manage. 

tsgsd3900 > ipcs -m | grep oraogpx2 
m 1912602658 0xbe82356d --rw-rw---- oraogpx2 dbaogpx2 
m 587202582 0xbe82356c --rw-rw---- oraogpx2 dbaogpx2 

use ipcrm command to remove memory in use to restart. 



prctl -n project.max-shm-memory -i project 3 --to check the correct allocated memory

project: 1001: user.orapgre2
NAME    PRIVILEGE       VALUE    FLAG   ACTION                       RECIPIENT
project.max-shm-memory
        privileged      5.00GB      -   deny                                 -
        system          16.0EB    max   deny                                 -

prctl -n project.max-shm-memory -r -v 37G -i project 3 --increased to 7G from 5G  (pls verify before execute )


add responsibility using sqlplus
================================
BEGIN
    fnd_user_pkg.addresp ('DBAREAD','SYSADMIN','SYSTEM_ADMINISTRATOR','STANDARD','System Administrator Responsibility',SYSDATE,SYSDATE + 2);
    COMMIT;
    END;
    /

Pinning objects 
===========
select 'execute dbms_shared_pool.keep('''||owner||'.'||name||''','''||decode(type,'PACKAGE BODY','P','PACKAGE','P','FUNCTION','P','PROCEDURE','P','TRIGGER','R','TYPE','T','SEQUENCE','Q')||''');' FROM v$db_object_cache
WHERE type NOT IN ('NOT LOADED','NON-EXISTENT','VIEW','TABLE','SEQUENCE','INVALID TYPE','CURSOR')AND loads>1 AND executions>loads AND executions>100 AND kept='NO'ORDER BY owner,namespace,type,executions desc;


RAC cluster commands
==================
crsctl status resource -t |grep -i jd1|egrep -v "acfs|vip|dg|agent"

ora.GPSPGJP1.lsnr
gpspgjp1_X
gpspgjp1_conc_mgr
gpspgjp1_dollaru
gpspgjp1_ebs_app_apppgjp101
gpspgjp1_ebs_app_apppgjp102
gpspgjp1_ebs_app_apppgjp1x01
gpspgjp1_ebs_app_apppgjp1x02
ora.gpspgjp1.db
tsgsp5010#
Status Services :
============================
crsctl status  resource gpspgjp1_ebs_app_apppgjp1x01
crsctl status  resource gpspgjp1_ebs_app_apppgjp1x02
crsctl status  resource gpspgjp1_ebs_app_apppgjp101
crsctl status  resource gpspgjp1_ebs_app_apppgjp102
crsctl status  resource gpspgjp1_dollaru
crsctl status  resource gpspgjp1_conc_mgr
crsctl status  resource gpspgjp1_X
Stop Application Services
==========================
crsctl stop  resource gpspgjp1_ebs_app_apppgjp1x01
crsctl stop  resource gpspgjp1_ebs_app_apppgjp1x02
crsctl stop  resource gpspgjp1_ebs_app_apppgjp101
crsctl stop  resource gpspgjp1_ebs_app_apppgjp102
crsctl stop  resource gpspgjp1_dollaru
crsctl stop  resource gpspgjp1_conc_mgr
crsctl stop  resource gpspgjp1_X
check for any third party Application like Aventx
=================================================== 8:14 AM 
i. login to admin node as application user (apppgjp1)
ii. fcmgr -admin -c stop ( to stop the Aventx unix services)
cd $FCHOME/bin
fcmgr -admin
>lc ( to check the status of Aventx unix services)
>stop ( to stop the Aventx unix services if running)
>e (exit from the prompt)
iii. $FCHOME/cfg/scripts/srvctl stop ( to stop fcsrv services)
iv. sh $CATALINA_HOME/bin/shutdown.sh ( to stop tomcat web manager services)
v. sh  /gpspgjp1/erpapp/appl/tools/AventX/oa/extproc/AventXDaemon/stop.sh
==================================================
Database and Listener
crsctl stop  resource ora.GPSPGJP1.lsnr
crsctl stop  resource ora.gpspgjp1.db

Status Services :
============================
crsctl status  resource gpspgjp1_ebs_app_apppgjp1x01
crsctl status  resource gpspgjp1_ebs_app_apppgjp1x02
crsctl status  resource gpspgjp1_ebs_app_apppgjp101
crsctl status  resource gpspgjp1_ebs_app_apppgjp102
crsctl status  resource gpspgjp1_dollaru
crsctl status  resource gpspgjp1_conc_mgr
crsctl status  resource gpspgjp1_X  8:14 AM 
Database and Listener
=====================================
crsctl start  resource ora.gpspgjp1.db
crsctl start  resource ora.GPSPGJP1.lsnr

Start Application Services
==========================
crsctl start  resource gpspgjp1_conc_mgr
crsctl start  resource gpspgjp1_X
crsctl start  resource gpspgjp1_dollaru
crsctl start  resource gpspgjp1_ebs_app_apppgjp1x01
crsctl start  resource gpspgjp1_ebs_app_apppgjp1x02
crsctl start  resource gpspgjp1_ebs_app_apppgjp101
crsctl start  resource gpspgjp1_ebs_app_apppgjp102
check for any third party Application like Aventx
===================================================
i. login to admin node as application user (apppgjp1)
ii. fcmgr -admin -c start ( to start the Aventx unix services)
cd $FCHOME/bin
fcmgr -admin
>lc ( to check the status of Aventx unix services)
>stop ( to stop the Aventx unix services if running)
>e (exit from the prompt)
iii. $FCHOME/cfg/scripts/srvctl start ( to stop fcsrv services)
iv. sh $CATALINA_HOME/bin/startup.sh ( to stop tomcat web manager services)
v. sh  /gpspgjp1/erpapp/appl/tools/AventX/oa/extproc/AventXDaemon/start.sh
 IMAP 
==========
-bash-3.2$ telnet gpsgnep1.tsg.ge.com 143
Trying 3.21.56.208...
Connected to gpsgnep1.tsg.ge.com (3.21.56.208).
Escape character is '^]'.
* OK Dovecot ready.
* login mailgnep xyz00abc
* OK Logged in.
* list * "*"
* LIST (\NoInferiors \UnMarked) "/" "DISCARD"
* LIST (\NoInferiors \UnMarked) "/" "PROCESSED"
* LIST (\NoInferiors \UnMarked) "/" "Trash"
* LIST (\NoInferiors \UnMarked) "/" "INBOX"
* OK List completed.
* logout
* BYE Logging out
* OK Logout completed.
Connection closed by foreign host.

Cluster name modify
====================
crsctl relocate resource appafmx102.appvip -n tsgxd2101 -f


To Fetch Version of Package from backend
===========================================
SELECT name ||' '|| text
FROM dba_source
WHERE line = 2
AND type LIKE 'PACKAGE BODY'
AND owner = 'APPS'
AND name = 'CSI_PROCESS_TXN_GRP'
ORDER BY name, type;