Tsql for database , size , free space or used space in database
hi,
i want to know how to find out database size
use master
declare @PageSize varchar(10)
select @PageSize=v.low/1024.0
from master..spt_values v
where v.number=1 and v.type='E'
select name as DatabaseName, convert(float,null) as Size
into #tem
From sysdatabases where dbid>4
declare @SQL varchar (8000)
set @SQL=''
while exists (select * from #tem where size is null)
begin
select @SQL='update #tem set size=(select round(sum(size)*'+@PageSize+'/1024,0) From '+quotename(databasename)+'.dbo.sysfiles) where databasename='''+databasename+''''
from #tem
where size is null
exec (@SQL)
end
select * from #tem order by DatabaseName
drop table #tem
The first select statement is to get how many kilobytes a data page has. SQL Server allocates disk space in the unit of data page. Currently each SQL server data page contains 8k bytes. The number of data pages allocated to each database file is recorded
in the sysfiles system table. With this information on hand the script creates a temporary table #tem and update the temporary table with size information which is gathered by querying the sysfiles table.
thx benedikt
Similar Messages
-
HT1349 I have a ipad an am looking for a good free app to use any idea
hi we are going on a trip I bought the 30.00 gps am trying to find a good app that is free any ideas their are so many
an App or a free GPS?
I use MotionX GPS Drive, love it!!!! Not free for voice turn by turn though.
Free Apps
Flipboard
USA Today
Podcasts
Enjoy -
Creating illustrations for large sizes, which software to use?
Hello everybody,
I'm an amateur, its my first discussion here,
My team from work will start a big project, we will build a space for visitors to an event. We will need several illustrations plots for the walls, the drawings has sizes like 6, 7 meters (width), with vectors and photos (jpeg, eps files). I have some experience with Ilustrator, but theres no way to create files larger than 577.95. Before I start, I want to hear your opinion about the best Adobe software to create these large size illustrations.I second that. Setup your Illustrator File at 25%. Your Photoshop files will be 600ppi @ 25%; so their final ppi will be 150 @ 100%; suitable for large format digital printing. Raster/Document settings ( illustrator ) should be set for high res or custom where any raster effects will retain their appearance when scaled 400%. You might be able to prep your files @ 50%; if so, just adjust resolutions.
-
Monitoring Used (%) space for tablespaces
Hi everyone,
I am currently using:
Redhat Linux ES 5 2.6.18 and also
Oracle 10g Release 2 for Linux x86 R10.2.0.3
While monitoring my Tablespaces using OEM Database Control, I notice that two tablespaces were almost full.
[SYSAUX] - Size: 290MB , Used 283MB (97% full)
[SYSTEM] - Size: 320MB, Used 313MB (98% full)
When I try to locate the datafiles of both tablespaces in its directory (/home/dba/oracle/oradata/oracle), it shows the allocated size (290MB for sysaux01.dbf & 320MB for system01.dbf) and not the used space.
I got three questions to ask over here:
1st- Why there isn't any warnings or alarms even though the tablespaces exceeds the critical size?
2nd- How come the datafiles shows the allocated size of the tablespaces and not the Used space?]
3rd- How can I find & monitor the actual used space of the tablespaces?
4th- I have enabled the AutoExtend function but I am worry whether is there any other concern?
I am still very new here.
Please pardon me for anything that is improper.
Looking forward for your expertise, guidance & help.
Thanks for your attention.
-Regards-
++ Kef Lim ++Hi,
Here you have some scripts:
TABLESPACE USAGE NOTES:
Tablespace Name - Name of the tablespace
Bytes Used - Size of the file in bytes
Bytes Free - Size of free space in bytes
Largest - Largest free space in bytes
Percent Used - Percentage of tablespace that is being used - Careful if it is more than 85%
select a.TABLESPACE_NAME,
a.BYTES bytes_used,
b.BYTES bytes_free,
b.largest,
round(((a.BYTES-b.BYTES)/a.BYTES)*100,2) percent_used
from
select TABLESPACE_NAME,
sum(BYTES) BYTES
from dba_data_files
group by TABLESPACE_NAME
a,
select TABLESPACE_NAME,
sum(BYTES) BYTES ,
max(BYTES) largest
from dba_free_space
group by TABLESPACE_NAME
b
where a.TABLESPACE_NAME=b.TABLESPACE_NAME
order by ((a.BYTES-b.BYTES)/a.BYTES) desc
SET SERVEROUTPUT ON
SET PAGESIZE 1000
SET LINESIZE 255
SET FEEDBACK OFF
PROMPT
PROMPT Tablespaces nearing 0% free
PROMPT ***************************
SELECT a.tablespace_name,
b.size_kb,
a.free_kb,
Trunc((a.free_kb/b.size_kb) * 100) "FREE_%"
FROM (SELECT tablespace_name,
Trunc(Sum(bytes)/1024) free_kb
FROM dba_free_space
GROUP BY tablespace_name) a,
(SELECT tablespace_name,
Trunc(Sum(bytes)/1024) size_kb
FROM dba_data_files
GROUP BY tablespace_name) b
WHERE a.tablespace_name = b.tablespace_name
AND Round((a.free_kb/b.size_kb) * 100,2) < 10
PROMPT
SET FEEDBACK ON
SET PAGESIZE 18
Set Termout On
Set Heading On
clear breaks
break on contents -
skip 1
compute Sum of alloc used free nbfrag on contents
column tblsp format a20 wrap heading "Tablespace Name"
column Alloc format 999,999 heading "Alloc|(Mb)"
column Free format 999,999 heading "Free|(Mb)"
column used format 999,999 heading "Used|(Mb)"
column pused format 990.9 heading "%|Used|Space"
column fragmax format 99,999.9 heading "Largest|Free|Ext.(Mb)"
column nbfrag format 99999 heading "Nb|frag"
column contents format a10 heading "Content"
column pct_ext_coal format 999 heading "% Ext.|Coal."
column ext_manage format a7 wrap heading "Ext.|M."
column autoext format a7 wrap heading "Auto|Ext."
select
contents
, nvl (dt.tablespace_name, nvl (fsp.tablespace_name, 'Unknown')) tblsp
, alloc
, alloc - nvl (free, 0) Used
, nvl (free, 0) Free
, ((alloc - nvl (free, 0)) / alloc) * 100 pused
, nbfrag
, fragmax
, dfsc.pct_ext_coal pct_ext_coal
, dt.ext_manage
, df.inc autoext
from
( select sum (bytes)/1048576 free
, max (bytes)/1048576 fragmax
, tablespace_name
, count(*) nbfrag
from sys.dba_free_space
group by tablespace_name
) fsp
, ( select sum(bytes)/1048576 alloc
, tablespace_name
, Decode(((inc * &Var_DB_BLOCK_SIZE)/1024), Null, 'No', 'Yes') inc
from sys.dba_data_files sddf
, sys.filext$ aut
where sddf.file_id = aut.file# (+)
group by tablespace_name
, Decode(((inc * &Var_DB_BLOCK_SIZE)/1024), Null, 'No', 'Yes')
Union
select sum(bytes)/1048576 alloc
, tablespace_name
, Decode(((increment_by * &Var_DB_BLOCK_SIZE)/1024), Null, 'No', 'Yes') inc
from sys.dba_temp_files sddf
group by tablespace_name
, Decode(((increment_by * &Var_DB_BLOCK_SIZE)/1024), Null, 'No', 'Yes')
) df
, ( select contents
, tablespace_name
, initial_extent/1024 initial_ext
, next_extent/1024 next_ext
, pct_increase
, max_extents
, min_extents
, Substr(extent_management,1,5) ext_manage
from dba_tablespaces
) dt
, ( select percent_extents_coalesced pct_ext_coal
, tablespace_name
from dba_free_space_coalesced
) dfsc
where
fsp.tablespace_name (+) = dt.tablespace_name
and
df.tablespace_name (+) = dt.tablespace_name
and
dfsc.tablespace_name (+) = dt.tablespace_name
order
by contents
, pused desc
;Cheers,
Francisco Munoz Alvarez
http://www.oraclenz.com -
Finding the size of db and size of used space
Greetings all good people.
Can you please help me find out about 2 database information?
One, I want to find out the size of a database =size of physical files.
and the size of data which is the size occupied in physical files.
We are about to start a new project and there is a table on the database but it is empty.
We want to be exporting data into this table but we want to make sure that there is enough space on the db before we start populating the table with data.
I believe the code below just gives me the size of the database.
select (bytes/1024/1024) as total_gigs from dba_segments where owner='BELL' and segment_name='$TABLE_NAME
But I want to know the total size of the database and how much size has been used already, much the same as you would want to know the size capacity of a hard drive and how much of the size has been used.
Sorry if my request is confusing.
Thanks a lot in advancedb size can be found out
select sum(bytes)/1024/1024/1024 from dba_data_files ;
and size of data is -- in the datafiles
select sum(bytes)/1024/1024/1024 from dba_segemnts ;
You can find out by below query .. the tablespace sizes -- would be DBSIZE
used space -- would be the actual occupied space.
select t.tablespace, t.totalspace as " Totalspace(MB)",
round((t.totalspace-nvl(fs.freespace,0)),2) as "Used Space(MB)",
nvl(fs.freespace,0) as "Freespace(MB)"
from
(select round(sum(d.bytes)/(1024*1024)) as totalspace,d.tablespace_name tablespace
from dba_data_files d
group by d.tablespace_name) t, (select round(sum(f.bytes)/(1024*1024)) as freespace,f.tablespace_name tablespace
from dba_free_space f
group by f.tablespace_name) fs
where t.tablespace=fs.tablespace (+)
order by t.tablespace -
Hi all,
I have a question regarding database size of my SAP Instance. My database by the way is Oracle 10g. I used the db02old transaction code. I got the ff: data in the space statistics:
Scale: Month Database
Date Values SIze/kb Free/kb
01.09.2009 Total 258744,320 27,741,824
01.08.2009 Total 258744,320 30,568,320
01.07.2009 Total 258744,320 34,444,288
01.06.2009 Total 258744,320 38,159,168
01.05.2009 Total 247152,640 29,041,344
01.04.2009 Total 247152,640 35,197,184
01.03.2009 Total 235560,960 39,262,144
01.02.2009 Total 205455,360 14,124,224
01.01.2009 Total 201175,040 14,463,168
01.12.2008 Total 197324,800 14,466,112
01.11.2008 Total 193474,560 14,282,560
01.10.2008 Total 188907,520 13,716,736
Note that the size from 01.06.2009 to 01.09.2009 has not changed. Does this mean that my database hasnt grown at all?
How can I determine the exact growth of my database? Im planning to do some projection on how long will it take before my entire disks are consumed so I need to gather some data with respect to my database growth per month.
Thanks in advance
Jun>
Aurelio Tadlas wrote:
> HI Anjali,
>
> Yes, that's precisely what happened. Now I know that the size indicated in db02old is not actually the size of the data contained in the database but rather, its the size of the tablespaces in my database.
>
> Thank you very much for the enlightenment.
>
> Best regards
Hi,
Sorry for "interrupt" here.
I'd recommend you to read the Oracle Database Concept Guide or go to any initial training (like ADM505)
There you will find out that with "database" Oracle refers to the physical files.
You can create a DB of 1 TB and that will be the database size, regardless of the data that is "inside".
That means that, at the end, you more or less understood.
DB02 shows the database size, not the amount of data that is inside the database -
Onedrive for business "the server is out of space"
hi,
- on premise SharePoint server 2013
- dedicated "my site" web application.
- the sites collection has the right quotas
- the server has a lot of space available.
OneFor Business client app have a strange behaviour:
- I synch small files < 1mb: works
- I synch one file of 300 mb, the client app (OneDrive for b) give me "the server is out of space"
- I remove my "300mb" file from my client and I synch one file of 50mb: works
- I synch other 10 files of 50mb and WORKS
- I retry to synch the file of 300mb and the client app give me "the server is out of space"
- I remove the file with the error and I try to synch a smaller file like 250 or 200 mb, same error.
- I try to synch other files of 50, 60, 70mb that added more than 300mb and WORKS!
what is the problem ?Have you looked at Site Quotas on the MySites in Central Administration on the SharePoint server, as well as Database size to validate that there isn't database size restrictions in place, and lastly, free space on the volume holding the database files
on the SQL Server?
Trevor Seward
Follow or contact me at...
  
This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs. -
Since I have the 64gb Macbook Air, disk space is precious to me.
Recently I have run into a problem, where whenever I delete a large file (over 1gb) Grandperspective sees it as Miscellaneous Used Space
Most of the things I delete are TV shows I download from itunes, drag them to my external HDD and delete them (always choosing 'delete file' from itunes)
I recently had it with a game I downloaded from the app store.
Before i used to make a backup, download the show, drag it to my external HDD and restore my computer from Time Machine, but that took too long.
When I 'get info' on my SSD there is 41.16gb free out of 59.81
But on Grandperspective, there is only 36.4gb free, 3gb miscellaneous used space and 16.2gb free space
How can I get rid of the miscellaneous used??
And stop is from appearing in the future??Ditto.....
My disk (1Tb) has about 150Gb of actual data on it.
Finder reporting 802 GB used. Various program, Whatsize, Grandperspective etc all reporting "650 Gb of Miscellaneous used Space. Used Cache Cleaner, no difference.
Been working on it for days, cannot find any rogue files to delete.
Apple support said "reinstall Snow Leopard" ... "make sure you have a back up"
The reason I don't have a back up is Time Machine (and another 3rd Party BU solution) wont work because it cant back up the HDD because it is too big!!
Any help would be much appreciated. -
What is the use of 'ALTER DATABASE CLOSE'?
Hello Everybody,
SQL*Plus: Release 10.1.0.2.0 - Production on Ma Aug 15 21:28:30 2005
Copyright © 1982, 2004, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> conn / as sysdba
Connected.
SQL> startup force
ORACLE instance started.
Total System Global Area 171966464 bytes
Fixed Size 787988 bytes
Variable Size 145750508 bytes
Database Buffers 25165824 bytes
Redo Buffers 262144 bytes
Database mounted.
Database opened.
SQL> select status from v$instance;
STATUS
OPEN
SQL> alter database close;
Database altered.
SQL> select status from v$instance;
STATUS
MOUNTED
SQL> alter database open;
alter database open
ERROR at line 1:
ORA-16196: database has been previously opened and closed
If i have to shutdown the instance and database then
WHAT IS THE USE OF 'ALTER DATABASE CLOSE' ?
I need explanation. Why should i shutdown?
Dont give me this answer.
ORA-16196: database has been previously opened and closed
Cause: The instance has already opened and closed the database, which is allowed only once in its lifetime.
Action: Shut down the instance.If you read the documentation you will see that there is no ALTER DATABASE CLOSE command.
This is an undocumented Oracle command, which we are not supposed to use. Consequently we are not allowed to complain about the way that it works. Instead we're supposed to use SHUTDOWN IMMEDIATE.
Cheers, APC -
can one tell how to find the database size?
Depends what you mean by database size and how you want the output to look?
Are you referring to the number of rows across all tables of a schema? The number of bytes used by the rows? The number of bytes used by the tablespaces? The number of bytes used by the datafiles? etc. etc. etc. So many options.
Be more clear in your requirements please. -
OrdImage using its own database session?
Hello,
I have been searching on the Internet and this forums, but I am unable to find an answer to my question, so I am asking it here: I have noticed that when a user enters to a screen with an OrdImage being displayed in it, the application module opens 2 database sessions instead of one. Furthermore, if I comment the af:media component used to display the OrdImage and I repeat the same test, only one database session is created. So for some reason, the OrdImage is using a separate database session from the rest of the screen.
Does the OrdImage type really need its own session? Is it possible to make it use the screen's one? Using two database sessions in the same screen is kind of a waste of resources, especially when that screen has a lot of users (like the one where he have the issue).
Thank you
Jordi
PS: by the way, I am using JDeveloper 11.1.1.4.0.I have just found [this article|http://jobinesh.blogspot.com.es/2011/07/tips-on-using-afmedia-to-display.html] about OrdImage in ADF, and I see that the pagedef property CustomInputHandler="OrdDomainValueHandler" (which is already set in my application) is used to retrieve some information that cannot be get through the View Object. Is it possible that this property is the responsible for that second connection?
Jordi -
How to enable shortcuts on "MAC" as in windows. (ie : Alt+I+I = for image size in PS )
Im using a mac system and adobe CS6 package. mainly works with Indesign, Illustrator and Photoshop.
But shortcuts doesn't works like Alt+I+I, Alt+I+S..... like that as on Windows computers.
Is there any way to enable "underline for shortcut letters" in mac for adobe products...?Here in Photoshop on Windows OS you can see the letter for shortcut shown as underlined
In Menu bar
F for File
E for Edit
and I for Image
We can press alt+F to list file menu
and alt+E to list Edit menu
Is there any option like this to enable shortcuts for menu bar in "MAC OC" -
Invalid sizes for free/used space
Hi All
We have an ipod mini on an XP system. Worked for a few months without any real problems. Recently we upgraded the computer and have had all sorts of issues. The itunes and ipod software is current, we've got all the latest hardware drivers, and xp updates. The itunes and ipod updater both report about 114.5Gb (yes, Gbytes) of space. The updater says that we are current with v1.4 of the software and 114.5Gbyte Capacity. Go into itunes and it says that the library is 431 songs=1.55Gbyte but when I click on the ipod in itunes it says that we have zero songs and 45.92Gbyte used space and 65.87 free which is obviously crap as its a 4G mini. The ipod will not appear in the explorer even though its set to be used for data.
And I have set it up on my toshi notebook and it works fine, so it is not the ipod itself.
Anyone, please help. It has chewed up almost 10 hours of my day today and I cannot figure it out.
TIASamantha, is it possible you have network drives or an external drive attached to your computer? What you're seeing is a symptom of Windows confusing the iPod's drive with these other drives and therefore showing the incorrect capacities. The solution is to assign the iPod a drive letter that is far removed from those other drives.
If this applies to your situation, see this:
Strange iPod behavior -
Function module to find out DATA BASE size, free space, used size
Is there any function module to find out DATA BASE , free space, used size
FM that gives all the details of the Date base
what data base, what is the size, free space, used space etc...
instead of writing case by case for each data base. based on CASE SY-DBSYS.Hi,
Check this FM:
DB02_ORA_SELECT_DBA_SEGMENT
alternatively u can check the tcode: DB02
thanks|
Mahesh -
How to know used space(size) of database or user?
Hi
can anyone let me know how to caluculate the used space(size) of the database ans user(schema).
Thanks in advance.Hello,
For the used space of the database you may use the following query:
select sum(bytes)/(1024*1024) "Mo" from dba_segments;For the used space of the Schemas you may use the query below:
select owner, sum(bytes)/(1024*1024) "Mo"
from dba_segments
group by owner;Hope this help.
Best regards,
Jean-Valentin
Maybe you are looking for
-
How to tell B1 that the state of a combo doesn't matter?
In the latest update to our B1, I noticed a form with a ButtonCombo on it that says "You Can Also..." and when you click on it, you get a choice of activities you can perform. I'm trying to replicate that behavior in my add-on, instead of cluttering
-
Cannot change Apple ID password as Apple ID is greyed out. how do I fix this
-
Many probelm in nokia belle fb2
1-can't open front camera(in belle fp 1 i can) 2-can't close camera(in belle fp1 ican) 3-sound of radio be slow(in pack 1it's the best sound of radio in all phone) 4-can't open many app it said close some application and app will close by iself an
-
A bit complicated to explain my question: When using Snow Leopard, have a folder A with - lets say 100 video clips. In an other folder B I have 120 Video clips. 100 of them are the same as in folder A and 20 new. I only need to copy the 20 new ones f
-
Iphone 3G and REAL GPS software?
Hi, My question is easy : When Apple will produce or open on Appstore REAL GPS software for iPhone? Because since July we can't use iPhone as a GPS in a car... And GPS only out a car says nothing. TomTom and others have define solution for iPhone but