Wednesday, January 2, 2013

Solution for Oracle 11g import export problem

If any table contain blank data export won't be proper in Oracle 11g.
Solution is Before Export we need to allocate extent to empty table.
Need to execute below query

select 'alter table '||table_name||' allocate extent;' from user_tables where segment_created = 'NO'

     above query will give  list of query to allocate extent to empty table like below

    alter table ELTRIX_TAG_MASTER allocate extent;
    alter table ELTRIX_TREND_CONFIG allocate extent;
    ...etc


   Then need to execute above list of queries , after that as usual  exp and imp commands will work without any issue.

Tuesday, January 1, 2013

How to find Query Execution Time in Oracle database?

select * from v$sql;

You will notice that you can further filter on lot of useful stuff.

For example:
Lets say you want to see only those queries coming via a JDBC Thin Driver, you can do:

select LAST_LOAD_TIME, ELAPSED_TIME, MODULE, SQL_TEXT elasped from v$sql
WHERE MODULE='JDBC Thin Client'
ORDER BY LAST_LOAD_TIME DESC


To see all the columns in this table:
desc v$sql

Finding open Cursor in particular user : 

select  sql_text, count(*) as "OPEN CURSORS", user_name from v$open_cursor where user_name='XXXXX' group by sql_text, user_name order by count(*) desc;