Thursday, May 17, 2012

get oracle job DDLs with dbms_metadata.get_ddl

Trick:
is you query dba_objects for your job objects, the objecttype is "JOB". However, if you use this type to extract your DDL definition, you get the following:

SQL> select dbms_metadata.get_ddl('JOB','COORD_INC_BACKUP','DBA_ADMIN') from dual;
ERROR:
ORA-31604: invalid NAME parameter "NAME" for object type JOB in function
SET_FILTER
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 116
ORA-06512: at "SYS.DBMS_METADATA_INT", line 4676
ORA-06512: at "SYS.DBMS_METADATA_INT", line 8552
ORA-06512: at "SYS.DBMS_METADATA", line 2881
ORA-06512: at "SYS.DBMS_METADATA", line 2747
ORA-06512: at "SYS.DBMS_METADATA", line 4333
ORA-06512: at line 1

no rows selected



Infact, the object type of your job object is not JOB, but PROCJOB
SQL> set long 2000000
SQL> set pagesize 0
SQL> select dbms_metadata.get_ddl('PROCOBJ','COORD_INC_BACKUP','DBA_ADMIN') from dual;


BEGIN
dbms_scheduler.create_job('"COORD_INC_BACKUP"',
job_type=>'EXECUTABLE', job_action=>
'/u01/app/oracle/scripts/rman_coord_inc.sh'
, number_of_arguments=>0,
start_date=>NULL, repeat_interval=>
NULL
, end_date=>NULL,
job_class=>'"DEFAULT_JOB_CLASS"', enabled=>FALSE, auto_drop=>TRUE,comments=>
'coordinated dump (incremental 1) using rman'
);
COMMIT;
END;




SQL> 


Tuesday, May 1, 2012

Optimizer statistics History Information

The following is used to get the optimizer statistics' history retention value and the timestamps for which statistics are available to be restored to the oracle database:
DECLARE
r number
a timestamp;
BEGIN
a:=dbms_stats.get_stats_history_availability;
r:=dbms_stats.get_stats_history_retention;
dbms_output.put_line(a||'--'||r);
END;

password file number of entries


1. At the time of creating a password file you specify the maximum number of 
distinct DBA and OPERs. But say already this step had been taken care and now I 
want to see in the exsisting password file the max. no of entries specified. 
Which data dictionary or anyother place where we can get this info.

take the size of the password file, subtract 1024 and divide by 128.  Eg:

$ ls -lag xxx yyy zzz
-rwSr-----   1 tkyte    other        3584 Dec 27 11:25 xxx
-rwSr-----   1 tkyte    other        6144 Dec 27 11:25 yyy


3584 -> 2560 -> 20, xxx has 20 entries
6144 -> 5120 -> 40, yyy has 40 entries