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 Posted / 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 |
Post New Answer View All Answers
i have 10gp file.now i need store in database..but database have only 7gb memory only..how do u store the file ?
What is dbcc? : sql server DBA
suppose you want to audit specific activities on sensitive data. How can you achieve that?
Can you redefine a table online?
How can you control the amount of free space in your index pages? : sql server DBA
What is a system database and what is a user database? : sql server DBA
how can you create a user-defined lock?
what is the use of ocr?
What is the importance of a recovery model? : sql server DBA
What is transparent data encryption? : sql server DBA
can u plz tell me what r the mandatory skills for getting job as a sql dba......plz send me all details thank you my id :k.mohann.mohan@gmail.com
How to start SQL Server in minimal configuration mode?
Where would you look for errors from the database engine?
What is the difference between clustered and non-clustered index? : sql server DBA
what are the performance views in an oracle rac environment?