I want to reuse a piece of code inside a stored procedure.
This piece of code need to be invoked multiple times inside
the procedure based on some different conditions. How to
achieve this?
Answer / mohapatra.gouranga@gmail.com
Best answer is:
SELECT df.tablespace_name "Tablespace",
df.bytes / (1024 * 1024) "Size (MB)",
SUM(fs.bytes) / (1024 * 1024) "Free (MB)",
Nvl(Round(SUM(fs.bytes) * 100 / df.bytes),1) "%
Free",
Round((df.bytes - SUM(fs.bytes)) * 100 /
df.bytes) "% Used"
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
UNION ALL
SELECT df.tablespace_name tspace,
fs.bytes / (1024 * 1024),
SUM(df.bytes_free) / (1024 * 1024),
Nvl(Round((SUM(fs.bytes) - df.bytes_used) * 100 /
fs.bytes), 1),
Round((SUM(fs.bytes) - df.bytes_free) * 100 /
fs.bytes)
FROM dba_temp_files fs,
(SELECT tablespace_name,bytes_free,bytes_used
FROM v$temp_space_header
GROUP BY tablespace_name,bytes_free,bytes_used) df
WHERE fs.tablespace_name (+) = df.tablespace_name
GROUP BY
df.tablespace_name,fs.bytes,df.bytes_free,df.bytes_used
ORDER BY 4 DESC;
| Is This Answer Correct ? | 0 Yes | 0 No |
Oracle 11g new features?
1. how do you delete duplicate rows in a table? 2. can you disable and enable primary key? 3. how do you move tables from one tablespace to another tablespace?????
What query tells you how much space a tablespace named "test" is taking up, and how much space is remaining?
How to bind a cobol module to a given job? I am not able to understand this concept.Can anyone help me out as how to carry out this task?
by issuing "alter tablespace begin backup;" what happens to tablespace?
Explain about your sql server dba experience? : sql server DBA
Which dictionary view(s) would you first look at to understand or get a high-level idea of a given Advanced Replication environment?
if monday take full backup and tuesday it was cumulative backup and wednesday we taken incremental backup, thursday some disaster happen then what type of recovery and how it will take?
what is the difference between hot backup n rman backup?
How do you open a cluster administrator? : sql server DBA
How would you best determine why your MVIEW couldn't FAST REFRESH?
What are the new features in sql server 2005 when compared to sql server 2000? : sql server DBA
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)