Friday, August 26, 2016

How can we see the Bind variable values when they are not in Timestamp and display the cursor plan

We can see the bind variable values with the below query.

 select * from table(dbms_xplan.display_cursor('4b5c6cp4gkup6',null,'+peeked_binds'));


How to display the cursor plan:

Run the cursor and execute the below sql:

select * from table(dbms_xplan.display_cursor);


Tuesday, June 21, 2016

Resetting the same old password in oracle or resolving password cannot be reused ORA-28007: or ORA-28003: password verification failed in oracle

Note:Password resetting is user own decision as per requirement.
Not to be copy pasted from this article and should not be used in production without CR.
This steps are described below keeping developement or perf testing environment in mind.

You might be doing this but still getting the above error:

SQL> select USER#,NAME,PASSWORD FROM USER$ where name='IPPADM' ;

     USER# NAME                           PASSWORD
---------- ------------------------------ ------------------------------
        26 IPPADM                         C42D1F57A9936520

ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME unlimited;

Then you might be setting the password to the older value;

alter user IPPADM identified by values 'C42D1F57A9936520';

not working same message.


select * from dba_profiles where profile='DEFAULT' and  RESOURCE_NAME in ('PASSWORD_REUSE_TIME') ;

alter profile DEFAULT limit PASSWORD_REUSE_TIME UNLIMITED;


alter user IPPADM identified by values 'C42D1F57A9936520';

No help not working.

Finally execute the following:

How to set password expiry to unlimited for a schema account in the DB and reset with the same old password:

select profile from dba_users where username='IPPADM'

DEFAULT

Check the different resource and limit for this profile.

select RESOURCE_NAME,LIMIT from dba_profiles where PROFILE='DEFAULT' and RESOURCE_NAME Like 'PASS%'

PASSWORD_LIFE_TIME
PASSWORD_REUSE_TIME
PASSWORD_REUSE_MAX
PASSWORD_VERIFY_FUNCTION
PASSWORD_LOCK_TIME
PASSWORD_GRACE_TIME

Change all the profile limit to unlimited including PASSWORD_VERIFY_FUNCTION which should be set to null.

ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME unlimited;

ALTER PROFILE DEFAULT LIMIT PASSWORD_REUSE_TIME unlimited;

ALTER PROFILE DEFAULT LIMIT PASSWORD_REUSE_MAX unlimited;

ALTER PROFILE DEFAULT LIMIT PASSWORD_GRACE_TIME unlimited;

ALTER PROFILE DEFAULT LIMIT PASSWORD_VERIFY_FUNCTION NULL;




How to set a samll amount for account lock time for a DB user:

ALTER PROFILE DEFAULT LIMIT PASSWORD_LOCK_TIME 0.001;



How to change the password expiry to unlimited for a service account:

Check the current status of the user say oracle.


[root@pdevspdb ~]# chage -l oracle
Last password change                                    : May 04, 2016
Password expires                                        : never
Password inactive                                       : never
Account expires                                         : never
Minimum number of days between password change          : 0
Maximum number of days between password change          : 99999
Number of days of warning before password expires       : 7


chage -I -1 -m 0 -M 99999 -E -1 username

Monday, June 20, 2016

How to do a proper cleanup of Oracle Stream configuration for a fresh install of Oracle Streams:

How to do a proper cleanup of Oracle stream configuration for a fresh install of Oracle Streams:


----------------

EXEC DBMS_APPLY_ADM.STOP_APPLY (APPLY_NAME => 'APPLY_STREAM');

EXEC DBMS_CAPTURE_ADM.STOP_CAPTURE (CAPTURE_NAME => 'CAPTURE_STREAM');

begin
DBMS_PROPAGATION_ADM.STOP_PROPAGATION(PROPAGATION_name  => 'pdsmar_TO_nixar');
end;
/

exec DBMS_PROPAGATION_ADM.DROP_PROPAGATION(propagation_name => 'pdsmar_TO_nixar',drop_unused_rule_sets => TRUE);

EXEC DBMS_CAPTURE_ADM.DROP_CAPTURE(CAPTURE_NAME=>'CAPTURE_STREAM',drop_unused_rule_sets => TRUE);

EXEC DBMS_APPLY_ADM.DROP_APPLY(APPLY_NAME=>'APPLY_STREAM',drop_unused_rule_sets => TRUE);

connect / as sysdba

exec dbms_streams_adm.remove_queue(queue_name=>'STRMADMIN.APPLY_q',cascade=>true,drop_unused_queue_table=>true);

exec dbms_streams_adm.remove_queue(queue_name=>'STRMADMIN.CAPTURE_q',cascade=>true,drop_unused_queue_table=>true);


drop user STRMADMIN cascade;


----
If above steps  required repeated for multiple environments we can write something line tis:

 BEGIN

    DBMS_STREAMS_ADM.REMOVE_STREAMS_CONFIGURATION;

  EXCEPTION
   WHEN OTHERS THEN



     -- Drop the APPLY queue on Site1
     dbms_streams_adm.remove_queue(queue_name=>'STRMADMIN1.STREAMS_APPLY_Q1',cascade=>true,drop_unused_queue_table=>true);

     -- Drop the CAPTURE queue on Site1
     dbms_streams_adm.remove_queue(queue_name=>'STRMADMIN1.STREAMS_CAPTURE_Q1',cascade=>true,drop_unused_queue_table=>true);
  END;
/

drop user STRMADMIN cascade;


Tuesday, May 31, 2016

Resolving issues for Oracle_Home is not set for Toad even Oracle client is available

Most often after installing Toad developer use to face this problem while starting Toad for Oracle.

Resolution:
Install Oracle 32 bit client on your machine for the same OS if Toad is below version 11.


Install Oracle 64 bit client in your machine for the same OS if Toad version is atleast 11.0...

Wednesday, May 18, 2016

How to use external table to copy table data in a file to a defined directory location in Oracle

External table is sometimes very useful to copy table data based on condition into a file to a defined directory location in Oracle:

CREATE OR REPLACE DIRECTORY  DP_DIR AS  '/tmp/oracle/';


GRANT READ, WRITE ON DIRECTORY SYS.DP_DIR TO TAPADM WITH GRANT OPTION;


Below will create the file;


CREATE TABLE TAPADM.TAP_COM_EVENT_DET_EXT
  ORGANIZATION EXTERNAL
   (
     TYPE ORACLE_DATAPUMP
     DEFAULT DIRECTORY DP_DIR
     LOCATION ('TAP_company_event_detail_xt.dmp')
   )
   AS select * from TAPADM.TAP_COMPANY_EVT_DETAIL where company_evt_detail_seq in(select COMPANY_EVT_DETAIL_SEQ from TAPADM.PTED_DIFF_1);


Now to copy the data to some other location at new DB from the above file we can use the below command or syntax.

CREATE TABLE TAPADM.TAP_COM_EVENT_DET_EXT
(
  COMPANY_EVENT_DETAIL_SEQ  VARCHAR2(255 CHAR),
  VERSION                   NUMBER(19),
  CREATOR_ID                VARCHAR2(30 CHAR),
  CREATED_DATE              TIMESTAMP(6),
  MODIFIER_ID               VARCHAR2(30 CHAR),
  MODIFIED_DATE             TIMESTAMP(6),
  REALM_ID                  NUMBER(19),
  EVENT_DETAIL_SUBTYPE      VARCHAR2(100 CHAR),
  COMPANY_FK                VARCHAR2(255 CHAR)
)
ORGANIZATION EXTERNAL
  (  TYPE ORACLE_DATAPUMP
     DEFAULT DIRECTORY DP_DIR
     ACCESS PARAMETERS 
       (  )
     LOCATION (DP_DIR:'TAP_company_event_detail_xt.dmp')
  )
REJECT LIMIT 0
NOPARALLEL
NOMONITORING;




Monday, May 16, 2016

Resolving PLS-00905: object GGATE.DDLAUX is invalid while installing Golden Gate in 11gR2


PLS-00905: object GGATE.DDLAUX is invalid


SQL> @ddl_setup

Oracle GoldenGate DDL Replication setup script

Verifying that current user has privileges to install DDL Replication...

You will be prompted for the name of a schema for the Oracle GoldenGate database objects.
NOTE: For an Oracle 10g source, the system recycle bin must be disabled. For Oracle 11g and later, it can be enabled.
NOTE: The schema must be created prior to running this script.
NOTE: Stop all DDL replication before starting this installation.

Enter Oracle GoldenGate schema name:ggate

Working, please wait ...
Spooling to file ddl_setup_spool.txt

Checking for sessions that are holding locks on Oracle Golden Gate metadata tables ...

Check complete.











Using GGATE as a Oracle GoldenGate schema name.

Working, please wait ...

DDL replication setup script complete, running verification script...
Please enter the name of a schema for the GoldenGate database objects:
Setting schema name to GGATE

CLEAR_TRACE STATUS:

Line/pos                                 Error
---------------------------------------- -----------------------------------------------------------------
No errors                                No errors

CREATE_TRACE STATUS:

Line/pos                                 Error
---------------------------------------- -----------------------------------------------------------------
No errors                                No errors

TRACE_PUT_LINE STATUS:

Line/pos                                 Error
---------------------------------------- -----------------------------------------------------------------
No errors                                No errors

INITIAL_SETUP STATUS:

Line/pos                                 Error
---------------------------------------- -----------------------------------------------------------------
No errors                                No errors

DDLVERSIONSPECIFIC PACKAGE STATUS:

Line/pos                                 Error
---------------------------------------- -----------------------------------------------------------------
No errors                                No errors

DDLREPLICATION PACKAGE STATUS:

Line/pos                                 Error
---------------------------------------- -----------------------------------------------------------------
No errors                                No errors

DDLREPLICATION PACKAGE BODY STATUS:

Line/pos                                 Error
---------------------------------------- -----------------------------------------------------------------
1464/9                                   PL/SQL: SQL Statement ignored
1466/25                                  PL/SQL: ORA-00942: table or view does not exist
1475/9                                   PL/SQL: SQL Statement ignored
1477/25                                  PL/SQL: ORA-00942: table or view does not exist
1489/9                                   PL/SQL: SQL Statement ignored
1491/25                                  PL/SQL: ORA-00942: table or view does not exist
1496/9                                   PL/SQL: SQL Statement ignored
1498/25                                  PL/SQL: ORA-00942: table or view does not exist
1503/9                                   PL/SQL: SQL Statement ignored
1505/25                                  PL/SQL: ORA-00942: table or view does not exist
1510/9                                   PL/SQL: SQL Statement ignored

Line/pos                                 Error
---------------------------------------- -----------------------------------------------------------------
1512/25                                  PL/SQL: ORA-00942: table or view does not exist
1595/4                                   PL/SQL: SQL Statement ignored
1596/20                                  PL/SQL: ORA-00942: table or view does not exist
1598/4                                   PL/SQL: SQL Statement ignored
1599/20                                  PL/SQL: ORA-00942: table or view does not exist
1614/27                                  PL/SQL: ORA-00942: table or view does not exist
1614/4                                   PL/SQL: SQL Statement ignored
1616/27                                  PL/SQL: ORA-00942: table or view does not exist
1616/4                                   PL/SQL: SQL Statement ignored


DDL IGNORE TABLE
-----------------------------------
FAILED: Table does not exist

DDL IGNORE LOG TABLE
-----------------------------------
FAILED: Table does not exist

DDLAUX  PACKAGE STATUS:

Line/pos                                 Error
---------------------------------------- -----------------------------------------------------------------
No errors                                No errors

DDLAUX PACKAGE BODY STATUS:

Line/pos                                 Error
---------------------------------------- -----------------------------------------------------------------
0/0                                      PL/SQL: Compilation unit analysis terminated
1/23                                     PLS-00304: cannot compile body of 'DDLAUX' without its
                                         specification

1/23                                     PLS-00905: object GGATE.DDLAUX is invalid


SYS.DDLCTXINFO  PACKAGE STATUS:

Line/pos                                 Error
---------------------------------------- -----------------------------------------------------------------
No errors                                No errors

SYS.DDLCTXINFO  PACKAGE BODY STATUS:

Line/pos                                 Error
---------------------------------------- -----------------------------------------------------------------
No errors                                No errors

DDL HISTORY TABLE
-----------------------------------
FAILED: Table does not exist

DDL HISTORY TABLE(1)
-----------------------------------
FAILED: Table does not exist

DDL DUMP TABLES
-----------------------------------
FAILED: Table does not exist

DDL DUMP COLUMNS
-----------------------------------
FAILED: Table does not exist

DDL DUMP LOG GROUPS
-----------------------------------
FAILED: Table does not exist

DDL DUMP PARTITIONS
-----------------------------------
FAILED: Table does not exist

DDL DUMP PRIMARY KEYS
-----------------------------------
FAILED: Table does not exist

DDL SEQUENCE
-----------------------------------
FAILED: Sequence does not exist

GGS_TEMP_COLS
-----------------------------------
FAILED: Table does not exist

GGS_TEMP_UK
-----------------------------------
FAILED: Table does not exist

DDL TRIGGER CODE STATUS:

Line/pos                                 Error
---------------------------------------- -----------------------------------------------------------------
126/9                                    PL/SQL: SQL Statement ignored
128/25                                   PL/SQL: ORA-00942: table or view does not exist
133/23                                   PL/SQL: ORA-02289: sequence does not exist
133/5                                    PL/SQL: SQL Statement ignored
707/16                                   PLS-00905: object GGATE.DDLAUX is invalid
707/5                                    PL/SQL: Statement ignored
992/27                                   PL/SQL: ORA-00942: table or view does not exist
992/4                                    PL/SQL: SQL Statement ignored


DDL TRIGGER INSTALL STATUS
-----------------------------------
OK

DDL TRIGGER RUNNING STATUS
------------------------------------------------------------------------------------------------------------------------
ENABLED
FROM "GGATE" ."GGS_SETUP"
              *
ERROR at line 2:
ORA-00942: table or view does not exist


FROM "GGATE" ."GGS_SETUP"
              *
ERROR at line 2:
ORA-00942: table or view does not exist


FROM "GGATE" ."GGS_SETUP"
              *
ERROR at line 2:
ORA-00942: table or view does not exist



LOCATION OF DDL TRACE FILE
------------------------------------------------------------------------------------------------------------------------
/u01/app/oracle/diag/rdbms/pspqa03/pspqa03/trace/ggs_ddl_trace.log

Analyzing installation status...


STATUS OF DDL REPLICATION
------------------------------------------------------------------------------------------------------------------------
ERRORS detected in installation of DDL Replication software components (6)

Script complete.
SQL>
SQL>
SQL>
SQL> grant create any table to ggs_user;
grant create any table to ggs_user
*
ERROR at line 1:
ORA-04098: trigger 'SYS.GGS_DDL_TRIGGER_BEFORE' is invalid and failed re-validation


SQL>
grant create any view to ggs_user;
SQL> grant create any view to ggs_user
*
ERROR at line 1:
ORA-04098: trigger 'SYS.GGS_DDL_TRIGGER_BEFORE' is invalid and failed re-validation


SQL>
SQL> grant create any procedure to ggs_user;
grant create any procedure to ggs_user
*
ERROR at line 1:
ORA-04098: trigger 'SYS.GGS_DDL_TRIGGER_BEFORE' is invalid and failed re-validation


SQL>
SQL> grant create any sequence to ggs_user;
grant create any sequence to ggs_user
*
ERROR at line 1:
ORA-04098: trigger 'SYS.GGS_DDL_TRIGGER_BEFORE' is invalid and failed re-validation


SQL>
SQL> grant create any index to ggs_user;
grant create any index to ggs_user
*
ERROR at line 1:
ORA-04098: trigger 'SYS.GGS_DDL_TRIGGER_BEFORE' is invalid and failed re-validation


SQL>
SQL> grant create any trigger to ggs_user;

grant create any trigger to ggs_user
*
ERROR at line 1:
ORA-04098: trigger 'SYS.GGS_DDL_TRIGGER_BEFORE' is invalid and failed re-validation


SQL> SQL> grant create any view to ggs_user;
grant create any view to ggs_user
*
ERROR at line 1:
ORA-04098: trigger 'SYS.GGS_DDL_TRIGGER_BEFORE' is invalid and failed re-validation


SQL>
SQL>
SQL> @ddl_remove

DDL replication removal script.
WARNING: this script removes all DDL replication objects and data.

You will be prompted for the name of a schema for the Oracle GoldenGate database objects.
NOTE: The schema must be created prior to running this script.

Enter Oracle GoldenGate schema name:ggate
Working, please wait ...
Spooling to file ddl_remove_spool.txt

Script complete.
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
SQL> grant create any table to ggate;

grant create any view to ggate;

grant create any procedure to ggate;

grant create any sequence to ggate;

grant create any index to ggate;

grant create any trigger to ggate;

grant create any view to ggate;
Grant succeeded.

SQL> SQL>
Grant succeeded.

SQL> SQL>
Grant succeeded.

SQL> SQL>
Grant succeeded.

SQL> SQL>
Grant succeeded.

SQL> SQL>
Grant succeeded.

SQL> SQL>

Grant succeeded.

SQL>
SQL>
SQL>
SQL>
SQL> @ddl_setup

Oracle GoldenGate DDL Replication setup script

Verifying that current user has privileges to install DDL Replication...

You will be prompted for the name of a schema for the Oracle GoldenGate database objects.
NOTE: For an Oracle 10g source, the system recycle bin must be disabled. For Oracle 11g and later, it can be enabled.
NOTE: The schema must be created prior to running this script.
NOTE: Stop all DDL replication before starting this installation.

Enter Oracle GoldenGate schema name:ggate

Working, please wait ...
Spooling to file ddl_setup_spool.txt

Checking for sessions that are holding locks on Oracle Golden Gate metadata tables ...

Check complete.











Using GGATE as a Oracle GoldenGate schema name.

Working, please wait ...

DDL replication setup script complete, running verification script...
Please enter the name of a schema for the GoldenGate database objects:
Setting schema name to GGATE

CLEAR_TRACE STATUS:

Line/pos                                 Error
---------------------------------------- -----------------------------------------------------------------
No errors                                No errors

CREATE_TRACE STATUS:

Line/pos                                 Error
---------------------------------------- -----------------------------------------------------------------
No errors                                No errors

TRACE_PUT_LINE STATUS:

Line/pos                                 Error
---------------------------------------- -----------------------------------------------------------------
No errors                                No errors

INITIAL_SETUP STATUS:

Line/pos                                 Error
---------------------------------------- -----------------------------------------------------------------
No errors                                No errors

DDLVERSIONSPECIFIC PACKAGE STATUS:

Line/pos                                 Error
---------------------------------------- -----------------------------------------------------------------
No errors                                No errors

DDLREPLICATION PACKAGE STATUS:

Line/pos                                 Error
---------------------------------------- -----------------------------------------------------------------
No errors                                No errors

DDLREPLICATION PACKAGE BODY STATUS:

Line/pos                                 Error
---------------------------------------- -----------------------------------------------------------------
No errors                                No errors

DDL IGNORE TABLE
-----------------------------------
OK

DDL IGNORE LOG TABLE
-----------------------------------
OK

DDLAUX  PACKAGE STATUS:

Line/pos                                 Error
---------------------------------------- -----------------------------------------------------------------
No errors                                No errors

DDLAUX PACKAGE BODY STATUS:

Line/pos                                 Error
---------------------------------------- -----------------------------------------------------------------
No errors                                No errors

SYS.DDLCTXINFO  PACKAGE STATUS:

Line/pos                                 Error
---------------------------------------- -----------------------------------------------------------------
No errors                                No errors

SYS.DDLCTXINFO  PACKAGE BODY STATUS:

Line/pos                                 Error
---------------------------------------- -----------------------------------------------------------------
No errors                                No errors

DDL HISTORY TABLE
-----------------------------------
OK

DDL HISTORY TABLE(1)
-----------------------------------
OK

DDL DUMP TABLES
-----------------------------------
OK

DDL DUMP COLUMNS
-----------------------------------
OK

DDL DUMP LOG GROUPS
-----------------------------------
OK

DDL DUMP PARTITIONS
-----------------------------------
OK

DDL DUMP PRIMARY KEYS
-----------------------------------
OK

DDL SEQUENCE
-----------------------------------
OK

GGS_TEMP_COLS
-----------------------------------
OK

GGS_TEMP_UK
-----------------------------------
OK

DDL TRIGGER CODE STATUS:

Line/pos                                 Error
---------------------------------------- -----------------------------------------------------------------
No errors                                No errors

DDL TRIGGER INSTALL STATUS
-----------------------------------
OK

DDL TRIGGER RUNNING STATUS
------------------------------------------------------------------------------------------------------------------------
ENABLED

STAYMETADATA IN TRIGGER
------------------------------------------------------------------------------------------------------------------------
OFF

DDL TRIGGER SQL TRACING
------------------------------------------------------------------------------------------------------------------------
0

DDL TRIGGER TRACE LEVEL
------------------------------------------------------------------------------------------------------------------------
0

LOCATION OF DDL TRACE FILE
------------------------------------------------------------------------------------------------------------------------
/u01/app/oracle/diag/rdbms/pspqa03/pspqa03/trace/ggs_ddl_trace.log

Analyzing installation status...


STATUS OF DDL REPLICATION
------------------------------------------------------------------------------------------------------------------------
SUCCESSFUL installation of DDL Replication software components

Script complete.

then run the other script:

SQL> @role_setup

GGS Role setup script

This script will drop and recreate the role GGS_GGSUSER_ROLE
To use a different role name, quit this script and then edit the params.sql script to change the gg_role parameter to the preferred name. (Do not run the script.)

You will be prompted for the name of a schema for the GoldenGate database objects.
NOTE: The schema must be created prior to running this script.
NOTE: Stop all DDL replication before starting this installation.

Enter GoldenGate schema name:ggate
Wrote file role_setup_set.txt

PL/SQL procedure successfully completed.


Role setup script complete

Grant this role to each user assigned to the Extract, GGSCI, and Manager processes, by using the following SQL command:

GRANT GGS_GGSUSER_ROLE TO <loggedUser>

where <loggedUser> is the user assigned to the GoldenGate processes.
SQL> GRANT GGS_GGSUSER_ROLE TO GGATE;

Grant succeeded.

SQL> @ddl_enable

Trigger altered.

Sunday, February 7, 2016

How to view the Checkpoint activites in Oracle Database


How to check to how many times you have to scan the short and long tables.
SQL> SELECT name, value
FROM v$sysstat
WHERE name IN ('table scans (short tables)',
'table scans (long tables)')
/
Try to reduce the number by creating proper table indexes. Note that the count for 'Long Tables scan' must be very small.


How to view the Checkpoint activites
Query the V$SYSSTAT directory view for the checkpoint process activity to monitor the checkpoint process.
SQL> SELECT name, value
FROM v$sysstat
WHERE name like 'background check%'
/
If the "background check started" value is greater than the "background check completed" value, you should increase the size of the REDO LOG files.


How to monitor REDO log file parallel write
Query the V$SYSTEM_EVENT directory view to see the Log File Parallel Write Event to monitor and tune a Redo Log file.
SQL> SELECT event, total_waits, time_waited
FROM v$system_event
WHERE event = 'log file parallel write'
/
The "Waits" column indicates a possible I/O problem.