Sunday, February 22, 2009

Materialized View Refresh Status

To know the materialized view refresh status along with their refresh time, you can issue following query to the database.

SELECT mview_name, refresh_mode, refresh_method, last_refresh_type, last_refresh_date FROM user_mviews;

Also to know the materialized view logs present in schema of a user, use this query

SELECT log_owner, master, log_table FROM user_mview_logs;

Sphere: Related Content

Tuesday, February 17, 2009

Script to create multiple startup screens in UNIX

Here is the scriipt that creates few startup screens on window.

Save this file in your home directory as MYSCREEN

execute it using screen -c {path to home}/MYSCREEN

startup_message off
vbell off
caption always "%{= bb}%{+b w}%n %h %=%t %c"
hardstatus alwayslastline "%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%<"
activity "Activity in %t(%n)"
shell -/bin/bash
screen -t SCREEN1
screen -t SCREEN2
screen -t SCREEN3
screen -t SCREEN4

This will create 4 screens named as SCREEN1,SCREEN2,SCREEN3 and SCREEN4 on your window

Sphere: Related Content

Script to export/import oracle schema

Here is the bash script that does the job of export and import of an oracle schema to another schema.

Save this file as EXPORT_IMPORT.

For exporting the schema type
EXPORT_IMPORT EXP

This file generates the schema dump in exp_database.dmp file and it also makes log of export process in exp_database.log file.

For importing the same exported exp_database.dmp dump file to another schema type
EXPORT_IMPORT IMP

if [ $# -lt 1 ]; then
echo "First argument to this file should be either EXP or IMP."
exit
fi
if [ "$1" = "EXP" ]; then
if [ $# != 2 ]; then
echo "No of arguments to this file should be two."
echo "USAGE: EXPORT_IMPORT EXP "
exit
fi
exp "$2" FILE=exp_database.dmp COMPRESS=N CONSISTENT=N CONSTRAINTS=Y GRANTS=Y INDEXES=Y RECORD=Y ROWS=Y Feedback=1000 LOG=exp_database.log
fi
if [ "$1" = "IMP" ]; then
if [ $# != 3 ]; then
echo "No of arguments to this file should be three."
echo "USAGE: EXPORT_IMPORT IMP "
exit
fi
from_user=`echo "$2" | cut -f1 -d'/'`
to_user=`echo "$3" | cut -f1 -d'/'`
imp userid="$3" fromuser="$from_user" touser="$to_user" file=exp_database.dmp buffer=64000 commit=y
fi

Sphere: Related Content

Thursday, February 12, 2009

Know all users on an Oracle database

To know all users on Oracle database, issue following command on sqlplus window

select * from all_users


Sphere: Related Content