Solved

How to get free disk space

Posted on 2007-12-06
3
1,335 Views
Last Modified: 2013-12-19
It is possible to get the total space used by the database by 'select sum(bytes) from dba_segments' but is it poosible to get the total free disk size on the computer/disk where the database works by using a command to the database?
0
Comment
Question by:gyrosab
3 Comments
 
LVL 27

Accepted Solution

by:
sujith80 earned 250 total points
ID: 20419020
>> by using a command to the database?
No, there is no direct way of communicating with the OS.
What you can do is: to have a C/Java stored procedure that runs your command and returns the results.
0
 

Author Comment

by:gyrosab
ID: 20419092
The thing is that the database is put on a networked computer/disk and the client is on another computer. I don't want to create any new communication stuff. I only want to use the database communication. What could I do?
0
 
LVL 73

Assisted Solution

by:sdstuber
sdstuber earned 250 total points
ID: 20419579
As sujith80 said, the db doesn't have that ability.  You have to use something external to the db.

You could create a unix cron job or windows scheduler or vms batch queue, etc  (depending on your OS) to perform an OS command and send the data to your db.

Or you can use a C external procedure to invoke an OS command  or you can use a java stored procedure.

Here's a simple example of the latter.
It will read execute a command (you have to grant access to that command) on the os and capture the standard output and standard error text and return it in a table collection of varchar2.


CREATE OR REPLACE TYPE VCARRAY AS TABLE OF VARCHAR2(4000)

CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "Run_Cmd" as
import java.io.*;
import java.sql.*;
import java.util.*;
import oracle.sql.*;
import oracle.jdbc.driver.*;

public class Run_Cmd{

    public static oracle.sql.ARRAY run_it(java.lang.String p_cmd)
    throws java.sql.SQLException,IOException
    {
        Runtime v_rt = Runtime.getRuntime();
        ArrayList v_output = new ArrayList();

       
        try
        {
            Process v_proc = v_rt.exec(p_cmd);
           
            BufferedReader v_stdout = new BufferedReader(
                                            new InputStreamReader(
                                                    v_proc.getInputStream()
                                                )
                                          );
            String v_line;
            while ((v_line = v_stdout.readLine()) != null)
                v_output.add(v_line);

            BufferedReader v_stderr = new BufferedReader(
                                            new InputStreamReader(
                                                    v_proc.getErrorStream()
                                                )
                                          );
            while ((v_line = v_stderr.readLine()) != null)
                v_output.add(v_line);
 
               
            v_proc.waitFor();    
           
        }

        catch (Exception e)
        {
            e.printStackTrace();            
        }

        Connection v_conn = new OracleDriver().defaultConnection();            
        ArrayDescriptor v_descriptor = ArrayDescriptor.createDescriptor( "VCARRAY", v_conn );            
        return new ARRAY( v_descriptor, v_conn, v_output.toArray() );
    }
}
/


0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now