473,440 Members | 1,735 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,440 software developers and data experts.

Finding table size (physical disk space)

101 100+
How do I find how much space a table takes up on a hard drive? Is there any call you can make that returns a size?

If so, how can I display this with asp?

Thanks for any help and insights.
Oct 4 '07 #1
6 23671
pbmods
5,821 Expert 4TB
Heya, Zensunni.

Check this out:
Expand|Select|Wrap|Line Numbers
  1. SELECT
  2.         `DATA_LENGTH`
  3.     FROM
  4.         `information_schema`.`TABLES`
  5.     WHERE
  6.     (
  7.             `TABLE_SCHEMA` = 'database name'
  8.         AND
  9.             `TABLE_NAME` = 'table name'
  10.     )
  11.     LIMIT 1;
  12.  
Oct 4 '07 #2
zensunni
101 100+
Ops, I'm retarded.

I meant to post in the MS SQL forum. Thanks for the reply though. MySQL is my DB of choice. Just wish all my clients could think that too :)

Thanks again and sorry.
Oct 5 '07 #3
pbmods
5,821 Expert 4TB
Heya, zensunni.

No problem.

I'm going to go ahead and move this thread to the MS SQL forum, where our resident Experts will be better able to help you out.
Oct 5 '07 #4
zensunni
101 100+
I'm pretty sure it's one of the system tables I have to access, which holds the information, but I'm unsure of which one.
Oct 11 '07 #5
iburyak
1,017 Expert 512MB
Let's assume you want to find out space that is taken by sysobjects.
Usually to see space used by the table you execute following statement:


Expand|Select|Wrap|Line Numbers
  1. sp_spaceused sysobjects

Because you need to query the same data I assume you are interested in reserved space by this table in a database. Use query below to select the same data directly from system tables. If you use SQL 2005 add schema name before system table name.

Expand|Select|Wrap|Line Numbers
  1. Declare @table varchar(50)
  2. select @table = 'sysobjects'
  3.  
  4. select ltrim(str((select sum(reserved)  
  5.                   from sysindexes
  6.                   where indid in (0, 1, 255)  
  7.                   and id = object_id(@table) ) 
  8.                 * d.low / 1024.,15,0) +  
  9.        ' KB')
  10.  from master.dbo.spt_values d  
  11.   where d.number = object_id(@table) 
  12.    and d.type = 'E'
Good Luck.
Oct 12 '07 #6
zensunni
101 100+
Thanks all. I used these commands:

To find all the tables:
SELECT * FROM sysobjects WHERE type = 'U'

To find out how much space was used by a table:
exec sp_spaceused '<tablename>'
Oct 30 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Dan Muey | last post by:
Howdy List! A couple questions about finding the disk space used by a = table/database: 1) First how can I get the size a table is taking up on disk? Is it the 'Data_length' field in: SHOW...
19
by: dchow | last post by:
Our database size is currently 4G and is incrementing at a rate of 45M/day. What is the max size of a SQL database? And what is the size beyond which the server performance will start to go down?
36
by: toedipper | last post by:
Hello, I am designing a table of vehicle types, nothing special, just a list of unique vehicle types such as truck, lorry, bike, motor bike, plane, tractor etc etc For the table design I am...
20
by: Guru | last post by:
Hi I have a table which contains number of rows. I want to fetch the last 5 records from the table. I know for the first 'n' records we can use FETCH FIRST n ROWS ONLY command. But i want to...
4
by: chettiar | last post by:
Hi, I am wanting to find out the size of a table for which I am using the following query: select c.card * b.columnlength from syscat.tables c, (select sum(a.avgcollen) as columnlength from...
6
by: Maxi | last post by:
I have 100 tabes in an Access database, every table has 1 filed with 100 names (records), no primary key assigned. I would like to find duplicates. Here is the criteria: The computer should...
1
by: Nils Rennebarth | last post by:
I have a table that is essentially a log where new entries are streaming in continually and from time to time I throw old entries away to keep the table from growing. I understand that in...
4
by: bienwell | last post by:
Hi all, I developed an web page in ASP.NET to upload file into the server. In the Web.config file, I declared <httpRuntime executionTimeout="1200" maxRequestLength="400000" /> The MAX...
0
by: zensunni | last post by:
How do I find how much space a table takes up on a hard drive? Is there any call you can make that returns a size? If so, how can I display this with asp? Thanks for any help and insights.
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.