Monday, February 20, 2012

Real size of database

I have a database which I do not think is really big, but when it was created the initial file sizes where set to very large amounts.

How do I get the actual size of the data?

When I do shrink database, SQL say there is no space to reclaim but when I back it up the backup is extreamly small, does this mean that shrink database will not shrink past the original size?

How do I resize the database to only the actual size needed?

Here is the result of sp_spaceused:

database_name database_size unallocated space

--

CCCca 99863.81 MB 96318.27 MB

reserved data index_size unused

5680 KB 3000 KB 2232 KB 448 KB

One thing about shrinking database files is that you cannot shink below the true size of your data. Imagine your database as a box filled with paper. If the box was half-filled, you can only shrink it to that size and no more than that. You cannot shirink it to 1/3 of the size of the box as you have 1/2 as data. Your database size includes not just data and metadata but indexes as well. From the data you posted here, you cannot shrink the database to below approx 3GB|||

u can use,

backup log databasename with truncate_only and then shrink the files and database.

|||

After I shrink the database still getting a database size of 134534.56 MB not 3GB. I ran the following:

backup log CCCca with truncate_only

DBCC SHRINKFILE (CCCca_Primary, TRUNCATEONLY);

DBCC SHRINKFILE (CCCca_Log, TRUNCATEONLY);

DBCC SHRINKFILE (CCCca_Analysis, TRUNCATEONLY);

DBCC SHRINKFILE (CCCca_AnalysisIdx3, TRUNCATEONLY);

DBCC SHRINKFILE (CCCca_AnalysisIdx, TRUNCATEONLY);

DBCC SHRINKFILE (CCCca_AnalysisIdx2, TRUNCATEONLY);

DBCC SHRINKFILE (CCCca_PrimeIdx, TRUNCATEONLY);

DBCC SHRINKFILE (CCCca_Word, TRUNCATEONLY);

DBCC SHRINKFILE (CCCca_WordIdx, TRUNCATEONLY);

DBCC SHRINKDATABASE (CCCca, TRUNCATEONLY);

but all I get is : "

DBCC SHRINKDATABASE: File ID 1 of database ID 5 was skipped because the file does not have enough free space to reclaim."

is this data base really 134534.56 MB or is it 3GB?

|||Truncating the log does not necessarily mean shrinking the database. It simply means you are freeing up space on your transaction log and committing the transactions in your database. Microsoft did not include the shrinking as part of the truncate option for the transaction log as this will incurr overhead when transactions starts occurring after the truncate command. You have to do them individually to shrink your database.|||I have same problem, I can't shrink the data and index files.... even there are unused space|||

Have you tried DBCC SHRINKFILE with the 'target_size' option specified

No comments:

Post a Comment