简体   繁体   中英

How do I shrink my database?

I have a 800 GB size database, and the storage is out of space. I have only 3,2 GB free space.

I have tried right click on database ->tasks -> shrink->file but nothing happened. It runs for 2 seconds.

i have tried with this, but at 99% the status return is suspended

DBCC SHRINKFILE (N'dbfilename', size)
GO

I have checked this query also:

SELECT d.name,    percent_complete,  session_id, start_time, status, command,  estimated_completion_time,  cpu_time,  total_elapsed_time
FROM 
    sys.dm_exec_requests E left join
    sys.databases D on e.database_id = d.database_id
WHERE
    command in ('DbccFilesCompact','DbccSpaceReclaim')

What should I do, because I am running out of space.

PS: my indexes are 90-99% defragmented.

You shouldn't shrink your database. Sounds like you may need to read up on database sizes in order to get your head wrapped around how they work.

If your indexes are that defragmented it's a good chance you have already shrank it. Have you checked the size? Search SO for sp_spaceused and you'll find a plethora of information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM