Tuesday, December 19, 2017

Extract range of lines from a text file in Unix

Input File    : orig-data-file
OutPut File : new-file

Line range 100 to 110



sed -n '100,110 p' orig-data-file > new-file
awk 'NR>=100&&NR<=110' orig-data-file > new-file
perl -ne 'print if 110..110' orin-data-file > new_file
-- get alert.log file for particular day
awk '/Jun 26/{c=6}c&&c --' alert_demo.log
grep -B1 -A1 'Jun 26' alert_demo.log




Wednesday, November 29, 2017

oratop

Pre- requisite

download oratop
set  oracle environment
helpful commands


oratop -i 5 / as sysdba
oratop -bdfi5 "/ as sysdba"
to remote database
oratop -f -i 5 sys/pass@db as sysdba


FOR HELP press h  and get the interactive key and enter in the main screen for example t is for table space






The UNION [ALL], INTERSECT, MINUS Operators

UNION Example The following statement combines the results of two queries with the UNION operator, which eliminates duplicate selected rows. This statement shows that you must match datatype (using the TO_CHAR function) when columns do not exist in one or the other table:
SELECT location_id, department_name "Department", 
   TO_CHAR(NULL) "Warehouse"  FROM departments
   UNION
   SELECT location_id, TO_CHAR(NULL) "Department", warehouse_name 
   FROM warehouses;
UNION ALL Example The UNION operator returns only distinct rows that appear in either result, while the UNION ALL operator returns all rows. The UNION ALL operator does not eliminate duplicate selected rows:
SELECT product_id FROM order_items
UNION
SELECT product_id FROM inventories;

SELECT location_id  FROM locations 
UNION ALL 
SELECT location_id  FROM departments;

location_id value that appears multiple times in either or both queries (such as '1700') is returned only once by the UNION operator, but multiple times by the UNION ALL operator.
INTERSECT Example The following statement combines the results with the INTERSECT operator, which returns only those rows returned by both queries:
SELECT product_id FROM inventories
INTERSECT
SELECT product_id FROM order_items;
MINUS Example The following statement combines results with the MINUS operator, which returns only unique rows returned by the first query but not by the second:
SELECT product_id FROM inventories
MINUS
SELECT product_id FROM order_items;

Monday, November 20, 2017

Extract DDL of scheduler job in oracle

set long 10000
select dbms_metadata.get_ddl('PROCOBJ','SCOTT_JOB','SCOTT') from dual;
Note : The job in sys cannot be extracted, so, copy it to another user and then extract
exec dbms_scheduler.copy_job('SYS.MY_JOB','SCOTT.MY_JOB');

Tuesday, August 29, 2017

Checking Swap Space Size and Usage



step 1
grep SwapTotal /proc/meminfo

step 2
vmstat 3 100
  The fields si and so show the amount of memory paged in from disk and paged out to disk, respectively

step 3
ls -al /var/log/sa | grep "Oct 12"
sar -W -f /var/log/sa/sa12
The fields pswpin and pswpout show the total number of pages brought in and out per second, respectively.

alternative example for yesterday
sar -f /var/log/sa/sa$(date +%d -d yesterday)

solutions
Adding more RAM.
Reducing the size of the SGA.
Increasing the size of the swap space