Search Articles

Queries to Monitor Expdp Datapump Jobs Status

Being a DBA, you often asked to perform and monitor expdp/impdp - datapump jobs on regular basis. In this post you will get varieties of queries using which you can start, stop, resume, kill and see the status of data pump jobs.

When the export or import job is in progress, you can press +C keys to get to the respective datapump  prompt or you can attach to the running job and then issue the STATUS command:

monitor-datapump-status


To monitor executing jobs using dba_datapump_jobs view:
set linesize 200
set pagesize 200
col owner_name format a12
col job_name format a20
col operation format a12
col job_mode format a20
SELECT 
owner_name, 
job_name, 
operation, 
job_mode, 
state 
FROM 
dba_datapump_jobs
where 
state='EXECUTING';



To get the detail information like SID, Serial#, and % of completion:
SELECT 
OPNAME, 
SID, 
SERIAL#, 
CONTEXT, 
SOFAR, 
TOTALWORK,
    ROUND(SOFAR/TOTALWORK*100,2) "%_COMPLETE"
FROM 
V$SESSION_LONGOPS
WHERE 
OPNAME in
(
select 
d.job_name
from 
v$session s, 
v$process p, 
dba_datapump_sessions d
where 
p.addr=s.paddr 
and 
s.saddr=d.saddr
)
AND 
OPNAME NOT LIKE '%aggregate%'
AND 
TOTALWORK != 0
AND 
SOFAR <> TOTALWORK;



To check the waiting status and wait event of the job waiting for:
SELECT   w.sid, w.event, w.seconds_in_wait
   FROM   V$SESSION s, DBA_DATAPUMP_SESSIONS d, V$SESSION_WAIT w
    WHERE   s.saddr = d.saddr AND s.sid = w.sid;



To check event event and wait class for a particular SID:
SQL> select COMMAND,STATE,WAIT_CLASS,EVENT,SECONDS_IN_WAIT from v$session where sid=7248 and SERIAL#=56639;



To monitor and perform various operations from the expdp/impdp prompt:
[oracle@orahow ~]$ expdp attach=Job_name
expdp / as sysdba attach=job_name
export>status
export>stop_job
export>start_jop
export>kill_job



To check the orphaned datapump jobs. For orphaned jobs the state will be NOT RUNNING.
SET lines 140
COL owner_name FORMAT a10;
COL job_name FORMAT a20
COL state FORMAT a12 
COL operation LIKE owner_name
COL job_mode LIKE owner_name
SELECT owner_name, job_name, operation, job_mode,
state, attached_sessions
FROM dba_datapump_jobs;



To check the alert log and query the DBA_RESUMABLE view.
select name, sql_text, error_msg from dba_resumable;



To kill the datapump jobs:
alter system kill session 'SID,SERIAL#' immediate;


That's all...if you have any suggestions or any other queries to monitor datapump jobs status, please comment us. We will definitely go through it and will include in this article.
Read more ...

How to Find Users having DBA Role in Oracle

The default DBA role is automatically created during Oracle Database installation. This role contains most database system privileges. Therefore, the DBA role should be granted only to actual database administrators. If you want to know which users have been granted the dba role then you need to query the dba_role_privs in the SYS schema.

USERS_HAVING_DBA_ROLES

The DBA role does not include the SYSDBA or SYSOPER system privileges. These are special administrative privileges that allow an administrator to perform basic database administration tasks, such as creating the database and instance startup and shutdown.

This role tells you the grantee, granted_role, whether they have admin option granted, and whether the role is their default role:


DBA_ROLE_PRIVS describes the roles granted to all users and roles in the database.

USER_ROLE_PRIVS describes the roles granted to the current user.



SQL> desc dba_role_privs
Name         Null?    Type
------------ -------- ------------
GRANTEE               VARCHAR2(30)
GRANTED_ROLE NOT NULL VARCHAR2(30)
ADMIN_OPTION          VARCHAR2(3)
DEFAULT_ROLE          VARCHAR2(3)



GRANTEE:               Name of the user or role receiving the grant
-----------------
GRANTED_ROLE:   Granted role name
--------------------------
ADMIN_OPTION:   Indicates whether the grant was with the ADMIN OPTION (YES) or not(NO)
-------------------------
DEFAULT_ROLE:   Indicates whether the role is designated as a DEFAULT ROLE for the user (YES) or not (NO)



Using below query you can find users having DBA privileges
SQL> select * from dba_role_privs where granted_role='DBA';
GRANTEE   GRANTED_ROLE ADM DEF
--------- ------------ --- ---
SYS       DBA          YES YES
SYSTEM    DBA          YES YES


There are many situations arises where you wanted to revoke the DBA roles granted to the user for the security reasons. The above query will help you to find the users having DBA privileges. 
Read more ...

dbca UnsatisfiedLinkError exception loading native library java.lang.UnsatisfiedLinkError

Getting below error while installing oracle 11g/12c database using DBCA. 

UnsatisfiedLinkError exception loading native library: njni11
java.lang.UnsatisfiedLinkError: /home/u01/app/oracle/product/11.2.0/db_1/lib/libnjni11.so: libclntsh.so.11.1: cannot open shared object file: No such file or directory
Exception in thread "main" java.lang.UnsatisfiedLinkError: get
at oracle.net.common.NetGetEnv.get(Native Method)
at oracle.net.config.Config.getNetDir(Unknown Source)
at oracle.net.config.Config.initConfig(Unknown Source)
at oracle.net.config.Config.<init>(Unknown Source)
at oracle.sysman.assistants.util.NetworkUtils.<init>(NetworkUtils.java:269)
at oracle.sysman.assistants.util.step.StepContext.<init>(StepContext.java:317)
at oracle.sysman.assistants.dbca.backend.Host.<init>(Host.java:778)
at oracle.sysman.assistants.dbca.ui.UIHost.<init>(UIHost.java:257)
at oracle.sysman.assistants.dbca.ui.InteractiveHost.<init>(InteractiveHost.java:54)
at oracle.sysman.assistants.dbca.Dbca.getHost(Dbca.java:164)
at oracle.sysman.assistants.dbca.Dbca.execute(Dbca.java:112)
at oracle.sysman.assistants.dbca.Dbca.main(Dbca.java:184)


You will be able to install oracle binaries successfully but during during SID creation you will get the above error.


Reason:

The prerequisites have not been met.


Resolution:


  1. Check the proper oracle binary version. Oracle binaries should be downloaded for proper OS versions.
  2. sqlplus: error while loading shared libraries: libclntsh.so.11.1" : The prerequisites have not been met. Make sure the "gcc" package has been installed.


I will suggest you to download the suggested oracle rpm packages and start the installation again.



List of supported Oracle 11G RPM packages:

rpm -Uvh binutils-2*x86_64*
rpm -Uvh glibc-2*x86_64* nss-softokn-freebl-3*x86_64*
rpm -Uvh glibc-2*i686* nss-softokn-freebl-3*i686*
rpm -Uvh compat-libstdc++-33*x86_64*
rpm -Uvh glibc-common-2*x86_64*
rpm -Uvh glibc-devel-2*x86_64*
rpm -Uvh glibc-devel-2*i686*
rpm -Uvh glibc-headers-2*x86_64*
rpm -Uvh elfutils-libelf-0*x86_64*
rpm -Uvh elfutils-libelf-devel-0*x86_64*
rpm -Uvh gcc-4*x86_64*
rpm -Uvh gcc-c++-4*x86_64*
rpm -Uvh ksh-*x86_64*
rpm -Uvh libaio-0*x86_64*
rpm -Uvh libaio-devel-0*x86_64*
rpm -Uvh libaio-0*i686*
rpm -Uvh libaio-devel-0*i686*
rpm -Uvh libgcc-4*x86_64*
rpm -Uvh libgcc-4*i686*
rpm -Uvh libstdc++-4*x86_64*
rpm -Uvh libstdc++-4*i686*
rpm -Uvh libstdc++-devel-4*x86_64*
rpm -Uvh make-3.81*x86_64*
rpm -Uvh numactl-devel-2*x86_64*
rpm -Uvh sysstat-9*x86_64*
rpm -Uvh compat-libstdc++-33*i686*
rpm -Uvh compat-libcap*


List of supported Oracle 12C RPM packages:

yum install binutils -y
yum install compat-libcap1 -y
yum install compat-libstdc++-33 -y
yum install compat-libstdc++-33.i686 -y
yum install gcc -y
yum install gcc-c++ -y
yum install glibc -y
yum install glibc.i686 -y
yum install glibc-devel -y
yum install glibc-devel.i686 -y
yum install ksh -y
yum install libgcc -y
yum install libgcc.i686 -y
yum install libstdc++ -y
yum install libstdc++.i686 -y
yum install libstdc++-devel -y
yum install libstdc++-devel.i686 -y
yum install libaio -y
yum install libaio.i686 -y
yum install libaio-devel -y
yum install libaio-devel.i686 -y
yum install libXext -y
yum install libXext.i686 -y
yum install libXtst -y
yum install libXtst.i686 -y
yum install libX11 -y
yum install libX11.i686 -y
yum install libXau -y
yum install libXau.i686 -y
yum install libxcb -y
yum install libxcb.i686 -y
yum install libXi -y
yum install libXi.i686 -y
yum install make -y
yum install sysstat -y
yum install unixODBC -y
yum install unixODBC-devel -y


Read more ...

How to convert scn to a timestamp in Oracle

Oracle has inbuilt features using which you can convert scn to timestamp and timestamp to scn. SCN_TO_TIMESTAMP takes as an argument a number that evaluates to a system change number (SCN), and returns the approximate timestamp associated with that SCN. This function is useful any time you want to know the timestamp associated with an SCN. In order to do this, Oracle has provided two packages called SCN_TO_TIMESTAMP and TIMESTAMP_TO_SCN.

convert-scn-to-timestamp



  • SCN is very important particularly when you are doing RMAN Recovery. 
  • Archivelog gap resolution and Recovery of Physical standby server.
  •  It can be used in an data pump export parameter file using FLASHBACK_SCN to ensure a consistent copy of the database at that point-in-time. 


HOW TO CONVERT SCN TO TIMESTAMP AND TIMESTAMP INTO SCN



Check the current scn of the database using below query.
SQL>select current_scn from v$database;

current_scn
--------------
4426538972




To get the timestamp value from the current scn number.
SQL> select scn_to_timestamp(4426538972) as timestamp from dual;

timestamp
-------------------------------
23-SEP-18 03.22.42.000000000 PM




To get the scn number from the timestamp.
SQL> select timestamp_to_scn(to_timestamp('23/09/2018 15:22:44','DD/MM/YYYY HH24:MI:SS')) as scn from dual;

SCN
----------
4426538972

Read more ...

How to stop Materialized view Auto Refresh in Oracle

A materialized view is a table segment or database object that contains the results of a query. A materialized view created with the automatic refresh can not be alter to stop refreshing. In order to disable that you must break the dbms_job that was created in order to refresh the view.

stop_mview_auto_refresh

Mview are local copies of data located remotely, or are used to create summary tables based on aggregations of a table's data. Materialized views, which store data based on remote tables are also, know as snapshots.


Steps to Disable Automatic Refresh of Materialized View.



STEP 1. Connect as mview owner and execute the below query.
select * from user_jobs where broken ='N';



STEP 2. In the WHAT column for the mview refresh job you will see:
dbms_refresh.refresh('"[OWNER]"."[MVIEW_NAME]"');



STEP 3. Take the JOB_ID form the job column and execute below procedure and mview will stop refreshing automatically:
begin
dbms_job.broken(JOB_ID,TRUE);
commit;
end;
/


Example:
begin
dbms_job.broken(25,TRUE);
commit;
end;
/



If you want the mview to start refreshing again just run the job.
begin
dbms_job.run(JOB_ID);
commit;
end;
/


Example:
begin
dbms_job.broken(25,FALSE);
commit;
end;
/


That's all about disabling the materialized view. If you want to stop materialized view from auto refresh just run the above procedure and check the status of the job
Read more ...

How to Flush a Single SQL Statement from the Shared Pool

Sometimes it is required to flush the single sql plan from the shared pool and it a good idea rather than flushing all the sql plan from the memory. After baselining or fixing the bad plan, DBA's wanted to kick out the sql plan from the memory to confirm, if optimizer is picking the correct plan.

flush_sql_id_shared_pool

I have seen that many guys simply use to flush the shared pool using alter system flush shared_pool statement which is not a good idea. Rather if you are struggling for fixing the bad plan of any single query, it is advisable to flush the single sql_id out of the memory.


STEP 1: Find Address and  hash_value of particular sql_id.
SQL> select ADDRESS, HASH_VALUE from V$SQLAREA where SQL_ID='251fjyn5fj84q';

ADDRESS HASH_VALUE
---------------- ------------------------

00000005DGEC9DE0 257655674



STEP 2: Purge sql plan from the shared pool by passing the above values.
SQL> exec DBMS_SHARED_POOL.PURGE ('00000005DGEC9DE0, 257655674', 'C');

PL/SQL procedure successfully completed.


Here, ‘C’ (for cursor)

STEP 3: Check if the plan still exist in the memory. If no rows selected then plan has been flushed out from the memory for that sql_id.

SQL> select ADDRESS, HASH_VALUE from V$SQLAREA where SQL_ID='251fjyn5fj84q';

no rows selected


In the above example, we have used the V$ view to find cursor information. If you are using RAC environment then change your query to use gv$sqlarea just in case the SQL statement you are looking for was executed on an instance other than the one you are currently logged into.


So this is all about flushing the sql statement from the shared pool. If you are facing such perforamce issues then you can use the above method to flush plan for the particular sql_id from the memory.


Read more ...

Best ways to Describe Table in Vertica


There are various ways to describe table in vertica, among some of them are listed below.

describe table

List table definition using \d:
=>  \d table_name;
=> \d schema_name.table_name;

It will list all the below details:
Schema
Table
Column
Type
Size
Default
Not Null
Primary Key
Foreign Key

oraadmin=> \d P1_orahow.u_acct_trans;
List of Fields by Tables            

  Schema  |        Table |         Column         |     Type    
----------+----------------------+------------------------+---------

 P1_orahow | u_acct_trans| act_id                 | numeric(19,0)
 P1_orahow | u_acct_trans| sfl_id                 | int          
 P1_orahow | u_acct_trans| sts_id                 | int          
 P1_orahow | u_acct_trans| act_record_number      | int          
 P1_orahow | u_acct_trans| act_record_address     | numeric(19,0)
 P1_orahow | u_acct_trans| act_record_length      | int          
 P1_orahow | u_acct_trans| act_record_type        | varchar(255)
 P1_orahow | u_acct_trans| act_duplicate_hashcode | int          
 P1_orahow | u_acct_trans| act_dup_fl             | char(1)      
 P1_orahow | u_acct_trans| act_filename           | varchar(255)
 P1_orahow | u_acct_trans| act_cust_id            | varchar(255)
 P1_orahow | u_acct_trans| act_acct_id            | varchar(255)
 P1_orahow | u_acct_trans| act_subs_id            | numeric(19,0)
 P1_orahow | u_acct_trans| act_re_name            | varchar(255)
 P1_orahow | u_acct_trans| act_item_type_name     | varchar(255)
 P1_orahow | u_acct_trans| act_item_type_code     | varchar(255)
 P1_orahow | u_acct_trans| act_event_time         | timestamp    
 P1_orahow | u_acct_trans| act_charge             | numeric(19,0)
 P1_orahow | u_acct_trans| act_price_plan_code    | varchar(255)
 P1_orahow | u_acct_trans| act_price_plan_name    | varchar(255)
 P1_orahow | u_acct_trans| act_event_inst_id      | varchar(255)
 P1_orahow | u_acct_trans| act_msisdn             | varchar(255)



List high level Table definition:
oraadmin=> \dt u_acct_trans_log;

                          List of tables

    Schema     |         Name         | Kind  |  Owner   | Comment
---------------+----------------------+-------+----------+---------
 P1_orahow      | u_acct_trans | table | oraadmin  |
 P1_orahow_test | u_acct_trans | table | ora_test |

(2 rows)



Describe from v_catalog.columns definition:
SELECT *
FROM   v_catalog.columns
WHERE  table_schema='P1_orahow'
       AND table_name='u_acct_trans'
ORDER  BY ordinal_position;



List table definition using table export:
oraadmin=> SELECT EXPORT_TABLES('', 'schema_name.table_name');
oraadmin=> SELECT EXPORT_TABLES('', 'P1_orahow.u_acct_trans');



List table definition by table export, which will give you the full create statement, including projections:
oraadmin=> SELECT export_objects('', 'schema_name.table_name');
oraadmin=> SELECT export_objects('', 'P1_orahow.u_acct_trans');



List all tables in Public Schema:
oraadmin-> \dt public.*;
                        List of tables

 Schema |           Name           | Kind  |  Owner  | Comment

--------+--------------------------+-------+---------+---------

 public | abc                      | table | oraadmin |
 public | cdr_offpeak_ts_temp      | table | oraadmin |
 public | cdr_percall_ts_temp      | table | oraadmin |
 public | gprs_ts_temp             | table | oraadmin |
 public | ipdr_ts_temp             | table | oraadmin |
 public | nik_cdr_offpeak_summary  | table | oraadmin |
 public | nik_cdr_per_call_summary | table | oraadmin |
 public | nik_gprs_cdr_summary     | table | oraadmin |
 public | nik_ipdr_summary         | table | oraadmin |
 public | nik_recharge_log_summary | table | oraadmin |
 public | recharge_log_ts_temp     | table | oraadmin |

(11 rows)


Read more ...

CONTACT

Name

Email *

Message *