by http://webgeektutorials.blogspot.com

Tuesday, July 10, 2012

Reload / Refresh Page in jQuery

Here is the code to refresh the page when u click on a button component. Its just like you press "F5" button to refresh page.
=======================Code begins =========================
<!doctype html>
<html lang="en-us">
<head>
<title>Reload/Refresh a Page in jQuery</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.js"> </script>

<script type="text/javascript">
$(document).ready(function() {
$('#Refresh').click(function() {
$("p").append("<strong>Now Refreshing page..</strong>");
location.reload();
});
});
</script>

Thursday, June 28, 2012

Oracle DBA script: Monitor user activity on the DB

Code :


set linesize 80
set verify off message off echo off pause off timing off time off
set feedback off
column o format a8 heading 'O/S|User'
column u format a10 heading 'Oracle|Userid'
column s format a12 heading 'R-S|Name'
column txt format a45 heading 'Current Statement' word

Oracle DBA script: Display hit ratio on Dictionary Cache

Increase Shared pool size to reach a 90% hit ratio on Dictionary Cache. Entries for dc_table_grants, d_user_grants, and dc_users should be under 5% each in the MISS RATE % column

Code: 
select
parameter,gets,Getmisses ,
getmisses/(gets+getmisses)*100 "miss ratio",
(1-(sum(getmisses)/ (sum(gets)+sum(getmisses))))*100 "Hit ratio"
from v$rowcache
where gets+getmisses <>0
group by parameter, gets, getmisses ;

Oracle DBA script: tablespace usage in %, blocks used etc

Code :
SELECT RPAD(t.name,18,' ') tablespace ,
LPAD(TO_CHAR(CEIL( (SUM(s.blocks)*COUNT(*)) / (SUM(f.blocks) *
POWER(COUNT(DISTINCT(f.file#)),2)) * 100 )),3) Pct ,
LPAD(TO_CHAR(TRUNC(SUM(f.blocks) * t.blocksize *
COUNT(DISTINCT(f.file#)) /
( COUNT(*) * 1024 * 1024 * 1024 ),2)),6) vol_G ,
LPAD(TO_CHAR(SUM(f.blocks) * t.blocksize * COUNT(DISTINCT(f.file#)) /
( COUNT(*) * 1024 * 1024 )),8) volume_M ,
TRUNC(SUM(s.blocks) * t.blocksize /
( 1024 * 1024 * COUNT(DISTINCT(f.file#))),2) taken_M ,
TRUNC( ( SUM(f.blocks) * t.blocksize * COUNT(DISTINCT(f.file#))
/ ( COUNT(*) * 1024 * 1024 ) )
- ( NVL(suM(s.blocks),0) * t.blocksize
/ ( 1024 * 1024 * COUNT(DISTINCT(f.file#)) ) ),2) remain_M
FROM sys.seg$ s, sys.ts$ t, sys.file$ f
WHERE s.ts# (+) = t.ts#
AND f.ts# = t.ts#
AND f.status$ = 2
GROUP BY t.name, t.blocksize
ORDER BY 1;

Oracle DBA script: Display Quota Allocated

Code:

select * from DBA_TS_QUOTAS
order by Tablespace_Name, Username;

Oracle DBA script: List the UGA and PGA used by each session

column name format a25
column total format 999 heading 'Cnt'
column bytes format 9999,999,999 heading 'Total Bytes'
column avg format 99,999,999 heading 'Avg Bytes'
column min format 99,999,999 heading 'Min Bytes'
column max format 9999,999,999 heading 'Max Bytes'
ttitle 'PGA = dedicated server processes - UGA = Client machine process'


compute sum of minmem on report
compute sum of maxmem on report
break on report

select se.sid,n.name, 
max(se.value) maxmem
from v$sesstat se,
v$statname n
where n.statistic# = se.statistic#
and n.name in ('session pga memory','session pga memory max',
'session uga memory','session uga memory max')
group by n.name,se.sid
order by 3
/

Oracle DBA Script : Monitor and veryfy deadlocks

Monitor and Verify DEAD Locks: Holding and Waiting Sessions

Code: 

set lines 80 echo on ver off timing on term on pages 60 feed on head on
spool DEAD_LOCK_WAITERS.LST

col " " for A25
col "Holding Session Info" for A25
col "Waiting Session Info" for A25

Thursday, June 21, 2012

Check DirectX version with DirectX Diagnostic Tools in Windows

How to detect DirectX version installed in Windows.

Microsoft DirectX is a group of technologies designed to make Windows-based PCs an ideal platform for running and displaying applications rich in multimedia elements such as full- color graphics, 3D animation, video and rich audio.

DirectX includes security and performance updates, along with many new features across all technologies, which can be accessed by applications using the DirectX APIs.

Friday, June 15, 2012

Oracle DBA Script : Keep tablespace usage less than 80%

Keep tablespace usage < 80% Keep contiguous free space

Code:
prompt ** Tablespace Space Usage **
prompt
prompt Goal: Keep tablespace usage < 80%
prompt . Keep contiguous free space
prompt
prompt Corrective Action: Add more space to prompt tablespaces
prompt Coalesce fragmented free space.
prompt
compute sum LABEL 'TOTAL' of SUM_B1 on report
compute sum LABEL 'TOTAL' of SUM_B2 on report
compute sum LABEL 'TOTAL' of b3 on report
BREAK ON REPORT
Column TS1 Format A25 Heading 'TS Name'
Column SUM_B1 Format 999,999,999,999 Heading 'Total Space|Allocated'
Column SUM_B2 Format 999,999,999,999 Heading 'Total Free|Space'
Column b3 Format 999,999,999,999 Heading 'Total Space|Used'
Column b4 Format 90.99 Heading 'Percent|Used'
Column b5 Format 990.99 Heading 'Percent|Free'
Column b6 Format 99,999,999,999 Heading 'Max Single|Free Space'
Column b7 Format 999,999 Heading 'Count|Free|Space'

Oracle Find Top 20 Longest Running Process in UNIX

Find the top 20 longest running processes in unix. Useful for high CPU bound systems with large number of users. Script also identifies processes without a oracle session.

Shell Script:
#!/bin/ksh
#
# Find Highest CPU used Oracle processes and get the Username
# and SID from oracle
# Only 3 character SIDNAME is displayed - Adjust the script according to your need.
#
date
echo " Top 20 CPU Utilized Session from `hostname`"
echo " ============================================"
echo "O/S Oracle Session Session Serial UNIX Login Ora CPU Time"
echo "ID User ID Status ID No ID MMDD:HHMISS SID Used"
echo "-------- ----------- -------- ------- ------- ------- ----------- --- --------"
ps -ef|grep LOCAL|cut -c1-15,42-79|sort -rn +2 | head -20 | while read LINE
do
SIDNAME=`echo $LINE | awk '{ print $4 }' | cut -c7-14`
CPUTIME=`echo $LINE | awk '{ print $3 }'`
UNIXPID=`echo $LINE | awk '{ print $2 }'`
#echo $SIDNAME $CPUTIME $UNIXPID
export ORACLE_SID=$SIDNAME
SIDNAME=`echo $ORACLE_SID | cut -c4-6`
export ORACLE_HOME=`/dba_script/bin/find_ohome.sh ${ORACLE_SID}`
export SHLIB_PATH=$ORACLE_HOME/lib:/usr/lib
export TMPDIR=/tmp

Oracle DBA Script : Free Space left in the tablespaces

col tablespace_name format a20 heading 'Tablespace'
col allocated format 99,999,999,999 heading 'Allocated'
col used format 99,999,999,999 heading 'Used'
col unused format 99,999,999,999 heading 'Unused'
col pct_used format 99.99 heading 'PCT Used'
spool tbsp_free.lst

select rtrim(a.tblsp) tablespace,
sum(to_use) allocated,
sum(to_use - nvl(free,0)) used,
sum(nvl(free,0)) unused,
sum(((to_use-(to_use - nvl(free,0)))*100)/to_use) pct_used
from tspace_alc a,
tspace_free b
where a.tblsp = b.tblsp (+)
group by a.tblsp;

Oracle DBA Script : This PL/SQL script reports the %space left on each tablespace

DECLARE
CURSOR cur_ts IS
SELECT tablespace_name,
SUM(bytes) bytes
FROM dba_data_files
GROUP BY tablespace_name;

CURSOR cur_ts_fs(p_ts VARCHAR2) IS
SELECT SUM(BYTES) fs,
MAX(bytes) mx
FROM dba_free_space
WHERE tablespace_name = p_ts;

lv_fs NUMBER := 0;
percent_fs NUMBER := 0;
large_fs NUMBER := 0;
lv_name V$database.name%TYPE;

BEGIN
DBMS_OUTPUT.enable(1000000);
SELECT name into lv_name from v$database;

Monday, June 11, 2012

Oracle DBA Script : Calculate buffer cache hit ratio in DB

Calculate buffer cache hit ratio in the database. Make sure it is more than 80 for an oltp environment and 99 is the best value.

Code:
column "logical_reads" format 99,999,999,999
column "phys_reads" format 999,999,999
column "phy_writes" format 999,999,999
select a.value + b.value "logical_reads",
c.value "phys_reads",
round(100 * ((a.value+b.value)-c.value) /
(a.value+b.value))
"BUFFER HIT RATIO"
from v$sysstat a, v$sysstat b, v$sysstat c
where

DBA Script: Look for number of extents

Look for the number of chunks which are free,look for also the number of extents being used by objects..primarily for indexes

Code:
set pagesize 300
spool frag.rpt
Prompt Fragmentation Report for the tablespaces
start ./title132.sql "Tablespace Fragmentation report" "frag.sql"
column sumbytes format 999,999,999,9999
column extents forma 999999999
column bytes format 999,999,999,999
column largest format 999,999,999,999
column Tot_Size format 999,999,999,999
column Tot_Free format 999,999,999,999
column Pct_Free format 999
column Chunks_Free format 9999
column Max_Free format 9999999999
set echo off

PROMPT SPACE AVAILABLE IN TABLESPACES

select a.tablespace_name,sum(a.tots) Tot_Size,
sum(a.sumb) Tot_Free,
sum(a.sumb)*100/sum(a.tots) Pct_Free,
(sum(a.largest)/1024)/1024 Max_Free,sum(a.chunks) Chunks_Free
from
(
select tablespace_name,0 tots,sum(bytes) sumb,
max(bytes) largest,count(*) chunks
from dba_free_space a
group by tablespace_name
union
select tablespace_name,sum(bytes) tots,0,0,0 from
dba_data_files
group by tablespace_name) a
group by a.tablespace_name;

column owner format a15
column segment_name format a30

Oracle DBA Script : Full Table Scan SQL Statement

The output of this script will display all sql statements in the shared pool that are doing full table scans.

Code:
--run this as sys in SQL worksheet
create table full_sql (sql_text varchar2(1000), executions number);
create or replace procedure p_findfullsql as

v_csr number;
v_rc number;
v_string varchar2(2000);

v_count number;

cursor c1 is select sql_text,executions from v$sqlarea where lower(sql_text) like '%select%';
begin
for x1 in c1 loop
delete from plan_table ;
Begin

Oracle DBA Script: Display IO by file

Display IO by file

Code:
select
substr(a.file#,1,2) "#",
substr(a.name,1,30) "Name",
a.status,
a.bytes,
b.phyrds,
b.phywrts
from v$datafile a, v$filestat b
where a.file# = b.file#;

Oracle DBA: SET AUTOTRACE Command

Haven't you ever thought there should be an easier way to do the EXPLAIN PLAN and TKPROF statistics than to edit your queries to add the commands (like EXPLAIN PLAN SET...), or to have to find or write a script that automates this? It should be an automatic part of SQL*Plus. Well, as of SQL*Plus 3.3 it is!! The command is called 'SET AUTOTRACE ON'!

Code:
The SET AUTOTRACE Command

In SQL*Plus 3.3 there is a little known command (at least I didn't know about it until recently) called SET AUTOTRACE. It is documented in the newest SQL*Plus document set, but who really reads the whole document set for changes? Well I did not. It is very simple to use. Just type the command:

SET AUTOTRACE ON

And then run your select statement. Example:

SQL> SET AUTOTRACE ON
SQL> SELECT d.deptno, d.dname, e.empno, e.ename
2 FROM dept d, emp e
3 WHERE d.deptno = e.deptno
4 /

DEPTNO DNAME EMPNO ENAME
---------- -------------- ---------- ----------
10 ACCOUNTING 7839 KING
30 SALES 7900 JAMES
30 SALES 7521 WARD

14 rows selected.

DBA Script: Track the space utilization of database over time

A script to track the space utilization of your database over time

Code:
you must create a table and run this script first

insert into monitor.space_check select a.tablespace_name, sum(a.bytes) free_space,
sysdate timestamp , sum(b.bytes) total_space
from dba_data_files a, dba_free_space b
where a.tablespace_name = b.tablespace_name group by a.tablespace_name;

exit
===============================================
Then run this script

===============================================

Monday, June 4, 2012

Oracle DBA Script : Calculating DB_Block Buffer Efficiency

This script uses the new way of calculating DB_Block Buffer Efficiency.
Notable Points : ( Performance Tuning )
Logical Read: consistent gets + db block gets
Hit-Ratio: (logical reads - physical reads) / (logical reads)
Our Aim: OLTP >= 95%, DSS/Batch >= 85%
Solution: enlarge block buffers, tune SQL, check appropriateness of indexes

Code:
select name, ((consistent_gets + db_block_gets) - physical_reads) /
(consistent_gets + db_block_gets) * 100 "Hit Ratio%"
from v$buffer_pool_statistics
where physical_reads > 0;

Oracle DBA Script : Generate Database Report

The script generates a report of tablesapces, data files, roll back segments, control files, log files, objects (user wise, valid and invalid)

Script:
set long 132
set serveroutput on
declare
cursor tablespaces is
select t.tablespace_name,
round(sum(bytes/(1024*1024)),0) ts_size
from dba_tablespaces t, dba_data_files d
where t.tablespace_name = d.tablespace_name
group by t.tablespace_name;
cursor datafiles is
select tablespace_name, file_id, file_name,
round(bytes/(1024*1024),0) total_space
from dba_data_files
order by tablespace_name;

cursor rollbacksegments is
select segment_name,
tablespace_name, r.status,
(initial_extent/1024) InitialExtent,
(next_extent/1024) NextExtent,
max_extents, v.curext CurExtent
From dba_rollback_segs r, v$rollstat v
Where r.segment_id = v.usn(+)
order by segment_name ;

cursor controlfiles is select name from v$controlfile;

cursor logfiles is select member from v$logfile;

Oracle DBA Script : Show data files usage

Script : 
set linesize 188
set pagesize 26
SET FEEDBACK OFF
set heading on
set echo off
set timing off
variable xxx char(150)

column "Tablespace" format a16
COLUMN "File ID" FORMAT 9999999
column "Data file" format a43
column "Mb" format 9,999,999
column "Blocks" format 9,999,999
column "Status" format a10
COLUMN "USED SIZE(Mb)" FORMAT 9,999,999,999
COLUMN "USED BLOCKS" FORMAT 999,999,999
COLUMN "USED USAGE" FORMAT A10
COLUMN "FREE SIZE(Mb)" FORMAT 9,999,999,999
COLUMN "FREE BLOCKS" FORMAT 999,999,999
COLUMN "FREE USAGE" FORMAT A10
COLUMN "TOTAL SIZE(Mb)" FORMAT 99,999,999,999
COLUMN "TOTAL BLOCKS" FORMAT 9999,999,999

break on "Tablespace"

Oracle DBA Script : Best Tablespace utilization report

select
f.tablespace_name,
a.total,u.used,f.free,round((u.used/a.total)*100)"% used",
round((f.free/a.total)*100) "% Free"
from
(select tablespace_name, sum(bytes/(1024*1024)) total from dba_data_files group by tablespace_name) a,
(select tablespace_name, round(sum(bytes/(1024*1024))) used from dba_extents group by tablespace_name) u,
(select tablespace_name, round(sum(bytes/(1024*1024))) free from dba_free_space group by tablespace_name) f
WHERE a.tablespace_name = f.tablespace_name
and a.tablespace_name = u.tablespace_name

Monday, May 21, 2012

jQuery: Disable context menu on right click

Using jQuery you can disable context menu when you right click on any HTML page. To do so add a very small   script in <HEAD> section of HTML page after linking it to jQuery.

Here is the script : 

<script type="text/javascript">
 $(function(){
 $("form").form();
 $(this).bind("contextmenu", function(e) {
e.preventDefault();
 });
});
</script> 

Monday, May 14, 2012

Oracle DBA Script : Monitor User

Displays the user and the text of the statement the user is executing

Code:
SELECT OSUSER,SERIAL#,SQL_TEXT
FROM V$SESSION, V$SQL
WHERE
V$SESSION.SQL_ADDRESS=V$SQL.ADDRESS 

AND 
V$SESSION.STATUS = 'ACTIVE';

Oracle DBA Script : Display DB uptime

Displays DB start time, and calculates how long the DB has been up.

Code:
set head off pages 0
Select
'Current System time and date is '||
To_Char(sysdate,'HH24:MI:SS " on " ddth
FMMonth YYYY')||chr(10)||'Database
'||NAME||' has been up since '||
To_Char(To_Date(a.value||b.value,'JSSSSS')
,'HH24:MI:SS " on " ddth FMMonth YYYY')
||chr(10)||' ( Which is
'||Trunc(sysdate-to_date(a.value||b.value,'JSSSSS'))||' days '||To_Char(To_Date(trunc(86400*(
(sysdate-to_date(a.value||b.value,'JSSSSS')
)-trunc(sysdate-to_date(a.value||b.value,'JSSSS'
)))),'SSSSS')
,'HH24 "hours" MI "mins and" SS "seconds )"')
from v$instance a,v$instance b,v$database
where a.key='STARTUP TIME - JULIAN'
and b.key='STARTUP TIME - SECONDS';

Oracle DBA Script : Detect Possible next extent failures

Script: 


Select
substr(sg.tablespace_name,1,30)Tablespace,
substr(sg.segment_name,1,30) Object,
sg.extents extents,
sg.next_extent next,
max(sp.bytes) available
From dba_free_space sp, dba_segments sg
Where sp.tablespace_name = sg.tablespace_name
Having max(sp.bytes) < sg.next_extent
Group by sg.tablespace_name,
sg.segment_name, sg.extents, sg.next_extent
Order by 1,2;

Oracle DBA Script : Mapping Database

Maps out the database physically with sizes and paths of all the physical files .It will give the names and sizes of rollback segments also..

Code:
spool dbmap.rpt
start title132.sql "Database Layout " "dbmap.sql"
prompt ================================
prompt Tablespace/Datafile Listing
prompt ================================
prompt
prompt
column "Location" format A60;
column "Tablespace Name" format A15;
column "Size(M)" format 999,990;

break on "Tablespace Name" skip 1 nodup;
compute sum of "Size(M)" on "Tablespace Name";
SELECT tablespace_name "Tablespace Name",
file_name "Location", bytes/1048576"Size(M)"
FROM sys.dba_data_files
Order by tablespace_name;
Prompt
Prompt ================================
Prompt Redo Log Listing
Prompt ================================
Prompt
Prompt
column "Group" format 999;
column "File Location" format A50;
column "Bytes (M)" format 99,990;

break on "Group" skip 1 nodup;

Oracle DBA Script : Export table data into text file

Creating a ascii text file of oracle table data with pipe delimited columns.

Code:
#!/bin/ksh
#First line in the .txt file is column names
USR=username/password
echo "set feedback off\n set pagesize 0\n
select 'XXTT' || table_name from user_tables ;" | sqlplus -s $USR | grep '^XXTT' | cut -c5- |
while read TABL
do
STR="nothing"
STR1="nothing"
echo "desc $TABL\n" | sqlplus -s $USR | tail +3 | grep "^[A-Z,a-z]" | awk '{print $1}' |
while read COLUM
do
if [ "$STR" = "nothing" ] then
STR=$COLUM
STR1=$COLUM
else
STR="$STR || '|' || $COLUM"
STR1="$STR1|$COLUM"
fi

Oracle DBA Script : Check error message in alert log

This Script search for Oracle error messages in last 100 lines in the alert log file , send a email message to concerned and keep log to a file.
You should pass name of ORACLE_SID as a parameter.
For eg: Ck_alerlog FINL


Code:
#!/usr/bin/sh
# Script Type: Shell (Bourne)
#
# Script name: ck_alertlog.sh
# Comments: Script checks last 100 lines of
# the alert log for specific
# Oracle errors, then pages or e-mails depending #on the error.
# Parameter: ORACLE_SID
# -------------------
# Revision Log
#
# 00/00/00 : Name of modifier - description
#of Modifications
#
#--------------------------------------------------
#-------------------------
SID=$1
DIR=/usr/local/bin/dbabin
ORACLE_SID=$SID; export ORACLE_SID
ORACLE_HOME=`grep -v "^[#]" /var/opt/oracle/oratab|grep $ORACLE_SID|cut -d: -f2
export ORACLE_HOME
cd $ORACLE_HOME/../..

ALERT_DEST=`pwd`
ALERT_DEST=$ALERT_DEST/admin/$SID/bdump
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
COLLECTOR=`tail -100 $ALERT_DEST/alert_$SID.log |egrep "ORA-255 |ORA-255:|ORA-0255|ORA-214|ORA-214:|ORA-00214|ORA-270|ORA-270:|ORA-00270|ORA-272|ORA-272:|ORA-00272|ORA-600|ORA-600:|ORA-00600|ORA-1122|ORA-1122:|ORA-01122|ORA-1578|ORA1578:|ORA-01578|ORA-1628|ORA-1628:|ORA-01628|ORA-1630|ORA-1630:|ORA-01630|ORA1631|ORA-1631:|ORA-01631|ORA-1632|ORA-1632:|ORA-01632|ORA-1650|ORA-1650:|ORA01650|ORA-1652|ORA-1652:|ORA-01652|ORA-1653|ORA-1653:|ORA-01653|ORA-1654|ORA1654:|ORA-01654|ORA-1655|ORA-1655:|ORA-01655"`
for i in $COLLECTOR
do

Oracle DBA Script : Change Sql Prompt

When you connect to sqlplus, you see the the following sql prompt. SQL>
By using this sql in the glogin.sql, you will see a prompt similar to the following:
SCOTT@DB-01>


Code:
The following code works on Oracle 8i (8.1.5, 8.1.6, 8.1.7).
You have to insert the following line of code in glogin.sql which is usually found in $ORACLE_HOME/sqlplus/admin

set termout off
set echo off
define X=NotConnected
define Y=DBNAME

Column Usr New_Value X
Column DBName New_Value Y
Select SYS_CONTEXT('USERENV','SESSION_USER') Usr From Dual;

--- The following does not work in 8.1.5 but works --- in 8.1.6 or above
Select SYS_CONTEXT('USERENV','DB_NAME') DBNAME From Dual;

Oracle DBA Script : Find out duplicate records in a Table

Code: 

SELECT primary_key FROM table_name
MINUS
(
SELECT DISTINCT primary_key
FROM table_name
)

You can also use * instead of the primary_key.
18. Description: This Script will help you to find out which Database you are presently
Connected to? If You are working on multiple Databases on different Servers using SQL*Net or Net8.
Code:

Oracle DBA Script : Return Information about constraint

Script prompts for a constraint name then it returns information about the constraint.

Code:

set lines 120
set serveroutput on size 100000
set scan on
clear buffer
set verify off
set feedback off
declare

l_constraint_name varchar2(30);
l_constraint_type varchar2(1);
l_table_name varchar2(30);
l_search_condition long;
l_related_constraint varchar2(30);
l_related_table varchar2(30);
l_rcolumn varchar2(30);
l_column varchar2(30);
l_query varchar2(400);
l_column_count integer;

cursor lc_constraint (p_constraint_name varchar2) is
select *
from dba_constraints
where constraint_name = p_constraint_name;

cursor lc_related_constraint(p_r_constraint_name varchar2)
is

Oracle DBA Script : Find Child table for given parent table

set echo off
set verify off
accept xTable prompt 'Enter Table Name: '
TTITLE LEFT 'Child Tables for the table: '&xTABLE
break on TABLE_NAME
SELECT B.TABLE_NAME, C.COLUMN_NAME,
C.POSITION
FROM USER_CONSTRAINTS A,
USER_CONSTRAINTS B,
USER_CONS_COLUMNS C
WHERE
A.CONSTRAINT_NAME=
B.R_CONSTRAINT_NAME
AND
A.TABLE_NAME = C.TABLE_NAME
AND
A.CONSTRAINT_NAME = C.CONSTRAINT_NAME
AND
A.TABLE_NAME = UPPER('&xTable')
ORDER BY B.TABLE_NAME, C.POSITION;

TTITLE LEFT 'Parent tables for the table: '&xTable

SELECT A.TABLE_NAME, C.COLUMN_NAME,
C.POSITION
FROM USER_CONSTRAINTS A,
USER_CONSTRAINTS B,
USER_CONS_COLUMNS C
WHERE
A.CONSTRAINT_NAME=B.R_CONSTRAINT_NAME
AND
B.TABLE_NAME = C.TABLE_NAME
AND
B.CONSTRAINT_NAME = C.CONSTRAINT_NAME
AND
B.TABLE_NAME = UPPER('&xTable')
ORDER BY A.TABLE_NAME, C.POSITION;

Oracle DBA Script : Find out two top values from a table

1. Finds the two highest salaries from table "emp".

Code:
select a.empno,a.sal
from emp a
where 2>
(
select count(*)
from emp
where sal>a.sal
);


2. Finds the two lowest salaries from table "emp".


Code:
select a.empno,a.sal
from emp a
where 2>
(
select count(*)
from emp
where sal<a.sal
)

Oracle DBA Script : Monitor File I/O

This script takes a snapshot of v$filestats at the current time and saves it. It then waits 10 seconds and takes another snapshot and reports on the delta.

Code:
col name for a50
set linesize 132
set pages 666
-- drop temporary table
drop table jh$filestats;
create table jh$filestats as
select file#, PHYBLKRD, PHYBLKWRT
from v$filestat;
prompt Waiting......
exec dbms_lock.sleep(10);

prompt NOTE: Only the top 10 files...
select * from (
select df.name, fs.phyblkrd - t.phyblkrd "Reads",fs.PHYBLKWRT - t.PHYBLKWRT "Writes",(fs.PHYBLKRD+fs.PHYBLKWRT) - (t.PHYBLKRD+t.PHYBLKWRT) "Total IO"
from v$filestat fs, v$datafile df, jh$filestats t
where df.file# = fs.file# and t.file# = fs.file#
and (fs.PHYBLKRD+fs.PHYBLKWRT) - (t.PHYBLKRD+t.PHYBLKWRT) > 0
order by "Total IO" desc )
where rownum <= 10
/

Oracle DBA Script : Show View Source

Code: 


SET HEADING OFF
SET ECHO OFF
SET FEEDBACK OFF
SET PAGESIZE 0
set numwidth 10

SELECT uv.view_name SORT1, 0 SORT2, 0 SORT3,
0 SORT4,
'create or replace view '||uv.view_name ||' ('
from dba_views uv
WHERE uv.owner = upper('&2')
and uv.view_name = upper('&1')
union all
SELECT utc.view_name SORT1, utc.column_id
SORT2, 0 SORT3, 0 SORT4,utc.column_name
from dba_tab_columns
WHERE utc.owner = upper('&2')
and utc.table_name = upper('&1')
and utc.column_id = 1
union all
SELECT utc.view_name SORT1, utc.column_id
SORT2, 0 SORT3, 0 SORT4,
' , '||utc.column_name
from dba_tab_columns
WHERE utc.owner = upper('&2')
and utc.table_name = upper('&1')
and utc.column_id <> 1
SELECT uv.view_name SORT1,999 SORT2,0
SORT3,0 SORT4,' )'
from dba_views uv
WHERE uv.owner = upper('&2')
and uv.view_name = upper('&1')
ORDER BY 1, 2, 3, 4;
SELECT uv.text
from dba_views uv
WHERE uv.owner = upper('&2')
and uv.view_name = upper('&1');
SELECT uv.view_name SORT1,999 SORT2,0
SORT3,0 SORT4,' ;'
from dba_views uv
WHERE uv.owner = upper('&2')
and uv.view_name = upper('&1');

Oracle DBA Script : Show Package Source

This script Extract package and package body source from the database.

Code:
COL SORT1 NOPRINT
COL SORT2 NOPRINT
COL SORT3 NOPRINT
COL SORT4 NOPRINT
BREAK ON SORT1 SKIP 1
set linesize 120
SET HEADING OFF
SET ECHO OFF
SET FEEDBACK OFF
SET PAGESIZE 0
SPOOL bldpack.sql

select 'set echo on ' from dual;
select 'spool bldpack.lst' from dual;
select 'Remark Build package definitions' from dual;

SELECT NAME SORT1, LINE SORT2,
'Create or Replace ' || TEXT
FROM USER_SOURCE
WHERE TYPE = 'PACKAGE' AND LINE = 1
UNION
SELECT NAME SORT1, LINE SORT2,TEXT
FROM USER_SOURCE
WHERE TYPE = 'PACKAGE' AND LINE > 1
UNION
SELECT NAME SORT1, 999999 SORT2, '/'
FROM USER_SOURCE
WHERE TYPE = 'PACKAGE' AND LINE =1
ORDER BY 1,2;

Oracle DBA Script : Active Transactions in Rollback Segments

column rr heading 'RB Segment' format a18
column us heading 'Username' format a15
column os heading 'OS User' format a10
column te heading 'Terminal' format a10

SELECT r.name rr,
nvl(s.username,'no transaction') us,
s.osuser os,
s.terminal te
FROM
v$lock l,
v$session s,
v$rollname r
WHERE
l.sid = s.sid(+) AND
trunc(l.id1/65536) = r.usn AND
l.type = 'TX' AND
l.lmode = 6
ORDER BY r.name
/

Monday, May 7, 2012

CarePointz app for iPhone / iPad

Health5C  proud to announce our new app "CarePointz" for iPhone / iPad users.

Do you have a jet set lifestyle or are you a frequent traveler!? This application is for you. You never sure what you are searching in a new place? Carepointz, which can help you pinpoint your nearest medical/ health related facility based on your choice. Best thing of this app is that it discovers the current location of user and suggests the best nearby medical/health facility. Health5C is improving this app day by day and may be within two or three weeks you will get new features with new version.

The tool finds places either through your internet connection Wi-Fi (if present) or through your Mobile Service Provider. CarePointz provides 35 different criteria's for search. You can see your current location along with normal or satellite or hybrid map view. Search results are also available offline to ensure you do not miss your findings, in case, you experience any network issue.

Friday, May 4, 2012

How to : jQuery UI Autocomplete - Combobox ( dropdown )

Convert your <select> into beautiful jQuery UI Combobox. Its been fun with jQuery and UI is really cool. This is what i got when finished. ( final output )


You can customize the widget as you want. for this you need jQuery UI , I downloaded my own jQueryUI Theme using Theamroller. You can download default theme or customize it as per your project need, just download it from here.  To do this cool widget i follow following steps.

Step 1:Add Javascripts and CSS to your page
Here i have downloaded 1.8.20 version and using same for this tutorial. For this widget i added few scripts and css style in header section of HTML page.

Tuesday, April 17, 2012

Free must have Medicine Reminder App for iPhone

Do you forget taking medications for yourself or reminding your family? 

Now we Health5C have solutions for this.

Last night suddenly i got a message on my phone saying congratulation our iPhone application in now in app store now. Our iPhone app is in appstore now and there's more to come to make ur lives easier and healthier!!  Medi Reminder allows you to schedule your intake of medication as prescribed by your Physician.

YES  Medicine Reminder app by Health5C  is 100% Free!!
"Medi Reminder" App allows you to manage not only your medications but also your family schedules with easy-to-use features:
  • Set medication reminders for multiple people (including your pets!).
  • Maintain a Medi-Kit - Medi Kit allows you to keep a list of all medicines with their stock. Take a snapshot of the medications, for easy identification.
  • You can manage a profile for each individual.
  • Automatically track stock, each time you take a medication.
  • Snooze your reminder if you are busy, to take your medications later.

So, this time we won't let you miss your medication with Medi Reminder!



Monday, April 16, 2012

Photoshop CS6 beta Ready to download


Adobe  Photoshop "World's best digital image editing software" beta CS6 is available for download now. It has new look and some really effective and magical tools. Adobe Photoshop CS6 beta is capable of 3D image editing and quantitative image analysis capabilities but these features are available in shipping version of Photoshop CS6 extended. You'll find lots of new ways to work faster and with greater creative freedom and precision when you dive into Photoshop CS6 beta.


You can free download adobe Photoshop CS6 beta by following link given below
Link:  http://labs.adobe.com

Here below  3  videos displays capabilities of new Photoshop CS6 beta.



Thursday, April 5, 2012

Why inkscape is not running fine with mac snow leopard?



Inkscape is very powerful and can do some amazing things. It's got too many features in some ways for my needs, I like it very much. This is my one of the favorite vector editing software.

I downloaded inkscape for snow leopard. When I run the app I get a menu that has nothing but one item: Inkscape, and it has no other options. No screen opens up, no other menu items pertaining to drawing appear. If I click the app where it sits on the app bar running along the bottom of my screen, everything on the bar.

I googled and after few research i found it required xQuartz to be installed first. i downloaded the latest xquartz from macosforge.org. The XQuartz project is an open-source X Window System that runs on OS X. Together with supporting libraries and applications.

I started xquartz it appeared on the dock and opened a little terminal window. Then I started inkscape.app. This time it showed the message to wait a few minutes while it did whatever. Then the Editor appeared. This time Inkscape worked fine and i'm doing some good svg kind of stuff in it.....

More info : Inkscape ,  macosforge.org and yeh google.



Wednesday, March 28, 2012

Download ChromePlus ? It's CoolNovo Now

Looking for Chrome Plus? It's Coolnovo now..

Now it is Maple browser and called  CoolNovo  is a improved chrome kernel, multi-label, multi-window of the green browser. The rapid dual-core, the boss key, privacy protection, ad filtering more than 20 enhancements. It is completely free, no trojan, no virus, no adware plug-in, without any functional limitations, do not bundle any third-party software. Can be the perfect running the Windows 2000/XP/2003/vista/7 and Linux operating systems.

Features
  • Maple browse specialized such as online banking website does not support chrome mode to add IE list so open these URLs will automatically switch to IE mode to open. Users can also add other sites according to their needs for IE list.
  • I Personally like this feature, Mouse gestures are generated when you press and hold the right mouse button to move the mouse track. Skilled in the Maple browser mouse gestures will save you a lot of time and bring you the efficient operation and use of fun. For example, through the left and right mouse gestures to achieve backward forward effect; under the left and right mouse gesture to close the current tab and activate the left and right labels.

Saturday, March 24, 2012

Download Free Pill Identifier App For Android

PILL IDENTIFIER BY Health5C For Android 2.2+

Yesterday was a lovely day, Health5C launched Pill Identifier App for Android 2.2 and up. I truly appreciate work of our developers, each and every one associated with us, Pill Identifier provides us valuable data regarding Pills by imprints, shapes and color. 

Identify those loose pills which you are not sure of. Get the detailed description of over 10000 medications found in the U.S. against Imprint, Shape and Color. Also determine the pills you are searching for based on Name, Pill Images, Strength, Ingredients, Manufacturer and NDC Code.


Powered by Health5C Wellness Solutions (P) Ltdhttp://www.health5c.com


Its FREE Application for Android 2.2 and UP, downloaded https://www.play.google.com

Stay Tuned here for future updates about Pill Identifier by Health5C and  Thanks to everyone who tried out the Pill Identifier! Your feedback will help us further improve Pill Identifier.

Wednesday, March 14, 2012

Tintii Photo Filter 2.6.0 for Adobe Photoshop

Tintii photo filter – a smart photo filter for affecting colour select effects. Also known in the manner that colour popping, think of Schindler’s List’s small quantity girl in red, or the dramatic manner of Sin City. Available as the pair a standalone program, and as a Photoshop stopple-in. 

Tintii 2.6.0 is now available for Windows, Mac OS X and Linux, introducing some recent interface innovations incorporated in Urban Lightscape, restoring plugin support for 32-bit Photoshop under Mac OS X, and fine-tuning the behaviour of lightness sliders. It also features a new application icon designed by the team at Creative Freedom.

Detailed changes are:
  • New application icon.
  • Centred image in preview pane and added textured background.
  • Changed lightness sliders to apply multiplicative rather than additive adjustments.
  • Added info bar for help messages.
  • Separated file types in open and save dialogs.
  • Fixed crashes in 32-bit Photoshop on Mac.

Wednesday, March 7, 2012

SAP Best Practices and Advantages with SQL Server

The advantages of using SAP with SQL Server  include:
  •  Improves performance. Enhancements in SQL Serverenable tune-up and auto-administration features on SAP application deployments.
  • Supports very large databases. mySAP and R/3 installations running on SQL Server  can accommodate larger and more complex databases. Multi-terabyte (TB) databases and 45,000 tables in a single mySAP database are becoming increasingly more common.
  • Offers advanced capabilities as standard features. Customers can take advantage of SQL Server  advanced capabilities such as Database Mirroring, Online Index Create, Database Snapshots, etc.
  • Contains comprehensive data management features. These data management features include advanced data mining, integration services, Extraction Transformation and Loading (ETL), BI, high availability, manageability, and security.
  • Runs on standard commodity servers and storage. SAP customers have two options for licensing SQL Server . When SQL Server is licensed through Microsoft and is used for more than one application, the database is licensed per processor, not per core, as is common with some competitors. This reduces the cost by a factor of three or greater. When SQL Server is licensed through SAP and is used for one application only, even greater savings can be realized.

Friday, March 2, 2012

Download Windows 8 Consumer Preview

Well Microsoft has released Windows 8 Consumer Preview and in a single day reached 1 million download.

Windows 8 Consumer Preview is prerelease software that may be substantially modified before it’s commercially released. Some product features and functionality may require additional hardware or software. If you decide to go back to your previous operating system, you'll need to reinstall it from the recovery or installation media that came with your PC. 

Microsoft says  Your Windows, everywhere , now it is cloud supported and once Sign in to any of your devices running Windows 8 your personalized settings and apps are right there. Windows 8 has two modes. One is called Metro-style and is built on a new "Windows Runtime", a modern mobile operating system in which apps are installed from an online store, sandboxed from one another and from the system for security, and easy to operate with your fingers. The other is the old Windows desktop, still needed by Microsoft for applications like Office and by the rest of us for all our existing applications.

Metro-style Windows follows a different philosophy than desktop Windows. Apps run full-screen (though with an option to have two tiled side by side) and are typically small and simple to use. Microsoft also designed the new runtime to make heavy use of asynchronous functions, which means that applications should remain responsive rather than freezing sulkily when performing long operations.

You can download Windows 8 right here : 



Hope you will like new interface and new experience with Windows 8.

Thursday, March 1, 2012

What happens when SQL Server executes a stored procedure or query ?

SQL Server performs a couple of internal steps before executing a query or stored procedure. The steps that interest us here are compilation and execution.
When SQL Server receives a query for execution, its execution plan may already be present in memory (the procedure cache); if not, SQL Server will have to compile the query before executing it.
The compilation process is divided into four parts: parsing, normalization, compilation and optimization.

Parsing

During this stage, SQL Server checks the query for syntax errors and transforms it into a complier-ready structure that it will use later to optimize the query. It does not check for object names or column names.

Normalization
At this stage, SQL Server checks all references to objects in the query. This is where we typically get the “Object not found” message when an object referenced in the query is not found in the database. SQL Server also checks to see if a query makes sense. For example, we cannot execute a table or select from a stored procedure.
Bear in mind that while we can optimize select, insert, and update statements, there is no way to optimize if, while, and for operators.

Tuesday, February 28, 2012

Detecting IPhone Device

There are few ways you can detect Iphone Device, and tell browser to behave accordingly. The iPhone launched with this user agent:

Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3

Todetect User Agent
Using ASP code
For those on a Windows Server, create a file called user-agent.asp and put the following lines of code in:
<%
Response.Write Request.ServerVariables (“HTTP_USER_AGENT”)
%>
Using PHP Code
For those on Linux based servers
<?php

Friday, February 17, 2012

Data Pump in Oracle Database 10g

Oracle Data Pump is a newer, faster and more flexible alternative to the "exp" and "imp" utilities used in previous Oracle versions. In addition to basic import and export functionality data pump provides a PL/SQL API and support for external tables.

Getting Started

For the examples to work we must first unlock the SCOTT account and create a directory object it can access:
CONN sys/password@db10g AS SYSDBA
ALTER USER scott IDENTIFIED BY tiger ACCOUNT UNLOCK;
GRANT CREATE ANY DIRECTORY TO scott;
 
CREATE OR REPLACE DIRECTORY test_dir AS '/u01/app/oracle/oradata/';
GRANT READ, WRITE ON DIRECTORY test_dir TO scott;

Table Exports/Imports

The TABLES parameter is used to specify the tables that are to be exported. The following is an example of the table export and import syntax:
expdp scott/tiger@db10g tables=EMP,DEPT directory=TEST_DIR 
dumpfile=EMP_DEPT.dmp logfile=expdpEMP_DEPT.log
 
impdp scott/tiger@db10g tables=EMP,DEPT directory=TEST_DIR 
dumpfile=EMP_DEPT.dmp logfile=impdpEMP_DEPT.log


For example output files see expdpEMP_DEPT.log and impdpEMP_DEPT.log.

The
TABLE_EXISTS_ACTION=APPEND parameter allows data to be imported into existing tables.

Schema Exports/Imports

The OWNER parameter of exp has been replaced by the SCHEMAS parameter which is used to specify the schemas to be exported. The following is an example of the schema export and import syntax:
expdp scott/tiger@db10g schemas=SCOTT directory=TEST_DIR 
dumpfile=SCOTT.dmp logfile=expdpSCOTT.log
 
impdp scott/tiger@db10g schemas=SCOTT directory=TEST_DIR 
dumpfile=SCOTT.dmp logfile=impdpSCOTT.log
For example output files see expdpSCOTT.log and impdpSCOTT.log.

Friday, January 6, 2012

Quick intro to SQL Server 2008


What is SQL Server 2008 RDBMS?

SQL Server 2008 is primarily thought of as a Relational Database Management System (RDBMS). It is certainly that, but it is also much more.SQL Server 2008 can be more accurately described as an Enterprise Data Platform. It offers many new features and even more enhanced or improved features from previous editions of the product. In addition to traditional RDBMS duty, SQL Server 2008 also provides rich reporting capabilities, powerful data analysis, and data mining, as well as features that support asynchronous data applications, data-driven event notification, and more.


Database Engine

The Database Engine is the primary component of SQL Server 2008. It is the Online Transaction Processing (OLTP) engine for SQL Server, and has been improved and enhanced tremendously in this version. The Database Engine is a high-performance component responsible for the efficient storage, retrieval, and manipulation of relational and Extensible Markup Language (XML) formatted data.
SQL Server 2008’s Database Engine is highly optimized for transaction processing, but offers exceptional performance in complex data retrieval operations. The Database Engine is also responsible for the controlled access and modification of data through its security subsystem. SQL Server 2008’s Database Engine has many major improvements to support scalability, availability, and advanced (and secure) programming objects.

SQL Server database : Regular maintenance

If you are a DBA it is very important for you to know maintenance plan in SQL Server. Generally we use SQL Enterprise Manager to perform regular maintenance of SQL database.

The information below does not cover everything you can do to maintain your SQL database in SQL Enterprise Manager. Before you must See your SQL documentation for details on what else you can do to maintain your database.

Backing up the transaction log is not compatible with simple recovery. If you have multiple databases with different recovery models, you can create separate database maintenance plans for each recovery model. In this way you can include a step to backup your transaction logs only on the databases that do not use the simple recovery mode.

Change recovery model to simple

Simple recovery mode is recommended because it prevents the transaction logs from swelling. In simple recovery, once a checkpoint is complete, the transaction logs for the time before the checkpoint are dropped from the active database. A checkpoint automatically occurs when the backup is made. We recommend having a database maintenance plan that performs a backup of the ePO database, together with "Simple Recovery". In this way, once a backup is successfully created, the portion of the transaction log in the active database will be dropped as it is no longer needed since a backup file exists.