Shell Script to find the tablespace size in oracle.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell Script to find the tablespace size in oracle.
# 1  
Old 07-24-2008
Shell Script to find the tablespace size in oracle.

Hi,

I need to execute a script to find the tablespace size in oracle.But i get an error.Smilie

Script Executed:-

Code:
#!/bin/ksh
ORACLE_SID= oracelinstance 
ORACLE_HOME= oracle path
PATH=$ORACLE_HOME/bin
export ORACLE_SID ORACLE_HOME PATH 

sqlplus username/password@oracle_instance <<-EOF
set serveroutput on
whenever sqlerror exit 1;
spool /tmp/tab_tmp.log
connect sys/standard as sysdba;
select tablespace_name, round((sum(bytes)/1024/1024),2) size_in_mb,
sum(greatest(maxbytes,bytes))/1024/1024 total_available,
round(((sum(bytes)/1024/1024)/(sum(greatest(maxbytes,bytes))/1024/1024)),2) pct_used
from DBA_DATA_FILES group by tablespace_name order by 1;
spool off
EOF
exit 0
 
Error :
 
SQL> 
SQL> connect sys/standard as sysdba;
Connected to an idle instance.
SQL> 
SQL> select tablespace_name, round((sum(bytes)/1024/1024),2) size_in_mb,sum(greatest(maxbytes,bytes))/1024/1024 total_available,
round(((sum(bytes)/1024/1024)/(sum(greatest(maxbytes,bytes))/1024/1024)),2) pct_used
from DBA_DATA_FILES group by tablespace_name order by 1;
 
select tablespace_name, round((sum(bytes)/1024/1024),2) size_in_mb,
sum(greatest(maxbytes,bytes))/1024/1024 total_available,
round(((sum(bytes)/1024/1024)/(sum(greatest(maxbytes,bytes))/1024/1024)),2) pct_used
from DBA_DATA_FILES group by tablespace_name order by 1
*
ERROR at line 1:
ORA-01034: ORACLE not available 

# 2  
Old 07-24-2008
this simply means that the oracle instance is down.

sql> startup immediate;

and then run your script again
# 3  
Old 07-24-2008
Hi,

first you have to check if all instances od oracle are running:

oracle> ps -ef |grep pmon --> you should see all oracle instances on output
# 4  
Old 07-24-2008
and try also to check the connection to your database:

sql> select from sysdate from dual; -->you should get system date and hour
# 5  
Old 07-26-2008
maybe the world oracle in your "ORACLE_SID= oracelinstance " mistake by oracel
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to find size of subdirectories

Hi I have to find size of subdirectory and automate it in CRON. Eg: parent directory name is NVBKP inside it there are several subdirectories I want to get the size of recent two subdirectories. I have tried ls -ltr diretory path | tail -2 But it is providing only size of the folder not... (8 Replies)
Discussion started by: ankit2012
8 Replies

2. Shell Programming and Scripting

Error in Scripting to monitor tablespace in Oracle DB

Buddies, I am writing the below script 'tab.sh' to monitor the tablespaces in Database:- ------------------------------- export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2 export PATH=$PATH:$ORACLE_HOME/bin export ORACLE_SID=orcl sqlplus system/oracle as sysdba <<EOF spool... (5 Replies)
Discussion started by: sandip250382
5 Replies

3. Shell Programming and Scripting

Script to check Oracle tablespace

I'm new to unix script, and I need to check the tablespaces daily, here is the script(quite simple), but it does not work. Did I missed something ? Please guide me, Many thanks ! #!/bin/sh echo "ORA TABLEASPACE:" sqlplus system/oracle as sysdba; set pagesize 9999; set linesize 132; ... (5 Replies)
Discussion started by: dehetoxic
5 Replies

4. Shell Programming and Scripting

tablespace monitoring script

I have prepared the below script to monitor the tablespace and alert the users whenever it reaches a threshold limit. #!/bin/sh . /home/.profile sqlplus -s $LOGON << .eof > $scripts/check_tablespace.temp set pages 0 select tablespace_name, free_percent from ( SELECT... (4 Replies)
Discussion started by: svajhala
4 Replies

5. Shell Programming and Scripting

alias to a shell script - tablespace size

I have developed the following shell script. The idea was to create an alias to execute it and return the tablespaces and their sizes from an oracle database. When I execute is via the alias, I have issues. So, here is the script first: > cat ts_size.sh #!/bin/ksh xwhere=" " xwild=" "... (8 Replies)
Discussion started by: desibabu
8 Replies

6. Shell Programming and Scripting

error in script path for tablespace usage

Hi , I am trying to run this script in crontab but I get errors. When I run it explicitly like ./monitor_tblsp from another location then it runs fine . I am messing somewhere with paths but I don't know where and how . Please help . Here is the error part ./monitor_tblsp: touch: not... (2 Replies)
Discussion started by: capri_drm
2 Replies

7. Shell Programming and Scripting

Need help in a shell script to edit a tablespace creation script.

Hi, CREATE TABLESPACE aps_blob_large01 DATAFILE '/c2r6u13/u03/oradata/qnoldv01/aps_blob_large0101.dbf' SIZE X 270532608 REUSE DEFAULT STORAGE (INITIAL 134217728 NEXT... (2 Replies)
Discussion started by: rparavastu
2 Replies

8. Shell Programming and Scripting

find process size script

Hello i am working on a project here is part of script that i need a help in get process SpectroSERVER current size if it exceed 3850 MB then #pkill -TERM ArchMgr and wait to succfull shutdown message from the log file to proceed to the next step #tail -f $SPECROOT/SS/DDM/ARCHMGR.OUT... (7 Replies)
Discussion started by: mogabr
7 Replies

9. UNIX for Dummies Questions & Answers

shell script to find files by date and size

Hi, I have a directory PRIVATE in which I have several directories and each of these have several files. Therefore, I need to find those files by size and date to back up those files in another directory. I don't know how to implement this shell script using ''find''. appreciate any... (1 Reply)
Discussion started by: dadadc
1 Replies

10. Shell Programming and Scripting

Shell script to Find file size

Hi, I am writing a script which takes the input file name and concat as a new file by appending a "1" to the file name. However i am not able to get the size of this new file. I am not sure where i am going wrong. Please check the script and help me get this working. #!/bin/sh ... (1 Reply)
Discussion started by: ragsnovel
1 Replies
Login or Register to Ask a Question