Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Understanding sqlplus syntax

Re: Understanding sqlplus syntax

From: Hans Forbrich <forbrich_at_yahoo.net>
Date: Wed, 31 Dec 2003 17:51:15 GMT
Message-ID: <3FF30C22.E0E7EF66@yahoo.net>


Jon wrote:
>
> Hi,
>
> I'm attempting to come up with a SQL script that calculates disk space
> usage with columns for Total, Free, Used, %Free & %Used. I think I've
> found several scripts that I can piece together into one script that
> will do what I'm looking for. However, being quite new to SQL
> scripts, I need to understand several areas of these scripts. Here is
> a sample of one of the scripts:
>
> select df.tablespace_name tablespace,
> df.bytes/(1024*1024) tot_ts_size,
> sum(fs.bytes)/(1024*1024) free_ts_size,
> df.bytes/(1024*1024)-(fs.bytes)/(1024*1024) used_ts_size,
> round(sum(fs.bytes)*100/df.bytes) ts_pct,
> round((df.bytes-sum(fs.bytes))*100/df.bytes) ts_pct1
> from dba_free_space fs, (select tablespace_name, sum(bytes) bytes
> from dba_data_files
> group by tablespace_name ) df
> where fs.tablespace_name = df.tablespace_name
> group by df.tablespace_name, df.bytes
>
> I know that "bytes" and "tablespace_name" are columns in the
> "dba_free_space" and "dba_data_files" System tables, but I don't know
> what the "df." and "fs." in the "df.tablespace_name", "df.bytes" &
> "fs.bytes" columns mean, along with the "df" and "fs" in the FROM
> clause. Any ideas?
>
> Thanks,

Look up the term Table ALIAS in the docco/text. (If you look at the SQL Reference manual at http://docs.oracle.com, specifically search for t_alias.) Then notice the section where you have

     from dba_free_space fs, (se...

HTH
/Hans

By the way, "dba_free_space" and "dba_data_files" are views, not tables. Received on Wed Dec 31 2003 - 11:51:15 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US