Script for checking schema satistics in Oracle


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script for checking schema satistics in Oracle
# 1  
Old 04-10-2006
Script for checking schema satistics in Oracle

I have a script which gives the output of schemas in Oracle DB :

Code:
#!/bin/ksh
ps -ef | grep -v grep | grep ora_pmon_$1 | wc -l | while read CONTROL
do
if [ "$CONTROL" -gt 0 ] ; then
   ORACLE_HOME=/u01/app/oracle/product/9.2.0
   export ORACLE_HOME
   PATH=$ORACLE_HOME/bin:$PATH:/bin:/usr/bin:usr/local/bin:.
   export PATH
   NLS_LANG=AMERICAN_AMERICA.UTF8 
   export NLS_LANG
   ORACLE_SID=$1
   export ORACLE_SID
   cd $2
   sqlplus "/ as sysdba" <<EOF
   set echo off
   set heading off
   set feedback off
   set termout off
   spool stats.sql
   select 'execute DBMS_STATS.GATHER_SCHEMA_STATS('''||username||''') ;' from dba_users
     where username <> 'SYS'
/
   spool off
   @stats.sql
   exit
EOF
fi
done

The code fails at the line @stats.sql . although I have tried giving absolute pathnames to the spooled file but the result is the same.
The script creates the stats.sql file but fails to execute it (--@stats.sql)
and disconnects from oracle..

Any thoughts?
rte
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How can I import a particular schema from full dump in Oracle?

Hi All, I have a full oracle dump file that I have exported from a production server. I want to import a specific schema out of the full dump. Is that possible in oracle. What will be the command for that? (6 Replies)
Discussion started by: Palak Sharma
6 Replies

2. Shell Programming and Scripting

Script will keep checking running status of another script and also restart called script at night

I am using blow script :-- #!/bin/bash FIND=$(ps -elf | grep "snmp_trap.sh" | grep -v grep) #check snmp_trap.sh is running or not if then # echo "process found" exit 0; else echo "process not found" exec /home/Ketan_r /snmp_trap.sh 2>&1 & disown -h ... (1 Reply)
Discussion started by: ketanraut
1 Replies

3. Shell Programming and Scripting

Parallel export of all oracle DB schema.

In my Oracle db there are 4 schemas. All the username & passwords are stored in a text file. I am using a while loop to export all the schemas. It read the first line and doing the export. For all users it export one by one. But I need all the schemas will exported simultaneously. i.e. all the... (1 Reply)
Discussion started by: priya001
1 Replies

4. Cybersecurity

LDAP rfc2307bis.schema or nis.schema?

Hi guys, we are implementing new ldap in our organization exclusively for Linux authentication purposes. As we are new to the subject, I would appreciate help regarding which schema to use to create group of users and accounts / passwords entries? I see both schemas listed in subject above... (0 Replies)
Discussion started by: Lastminute
0 Replies

5. Emergency UNIX and Linux Support

Toad for Oracle 11G Schema browser

Need a help ..Schema browser in Toad not listing the tables when i connected to Oracle 11g schema did any body faced the issue... ? How to resolve the issue.. I need it asap thats y posted here Thanks (5 Replies)
Discussion started by: girija
5 Replies

6. UNIX and Linux Applications

Toad for Oracle 11G - schema browser not working

Need a help Schema browser in Toad not listing the tables when i connected to Oracle 11g schema did any body faced the issue... ? How to resolve the issue (0 Replies)
Discussion started by: girija
0 Replies

7. UNIX for Dummies Questions & Answers

creating a schema

hi guys, Unix dummy here. I need help creating a script for class. The assignment reads as follows: create a script that will create a new schema in schema.txt, it must accept 7 arguments (the first being the name of the schema) the other 6 being the 6 field names. the schema has to be tested... (1 Reply)
Discussion started by: zodester
1 Replies

8. Solaris

checking for existence of table in oracle

how do i check from solaris for existence of table in oracle..?? the requirement is, that if the table does not exist, it is created.. :confused: The logic will be something like: if table exists then insert into table else create table insert into table end if (0 Replies)
Discussion started by: kjs
0 Replies
Login or Register to Ask a Question