I’m trying to make my database smaller but I have no clue where all the data is spent.
Is there software that allows one to identify how much size a table and/or a column uses?
Are there other things besides the tables that would take space? Does the software support listing that?
Leaving aside the inherrent costs of the tables, indexes etc, which either you can’t or may not really want to do anything about, and assuming you mean disk foot print.
If you had a table with an int and a VarChar(128) int is 4, varchar(128) is so that’s 132 bytes * number of rows.
Is this for downloading / installation? If so you might find googling DBCC ShrinkDB, Recovery options useful.
Careful where you go with this, swapping your ints to words, or truncating your varchars means good bit of messing about in your code. Equally normalising/denormalising has it’s own costs. Also the filesize you want to pay atention to is backup not the mdb on disk which by default is always grow and so will be at the maximum ever capacity. If you’ve been developing a lot with it and not backing up, it could be stupidly high.
Right
First each time you run out of space compact will from by 1 to 16 pages dependant on new needs.
Second run out of space means there isn’t enough to store row contiguously, and CE dpoes not recover space unless you compact, so it’s more than posiible if you do a lot of inserts then some deletes, the some more inserts some or all of the space that was used will not be reused.
So before you try this compact, otherwise it will be of dubious value
In code or attach SQL Server manager
select *
from INFORMATION_SCHEMA.Columns
will give you a nice bunch of info about your db
then it’s just a question of writing a query to sum up based on Data_type and Character_Maximum. That however will give you the theoretical maximumsize per row. so NVarChar(50) has a maximum of 100 bytes, (image is a gig !) but if it’s got ‘Fred’ in it it will be 8..
Once you have a row size multiply it by count for the table
Actual sizes would mean whapping through and doing a datasize for each actual column on every row, which might be difficult with CE.
Or you could do it all in code,
If you want to havea whack at it and come back withn issues be my guest, but you aren’t paying me enough to do it for you. 🙂
Though I just found this, hurrah for google, maybe it will do what you want.
SQl Compact Query Analyser