1. 程式人生 > 資料庫 >收縮資料庫,以用友資料庫為例

收縮資料庫,以用友資料庫為例

 1、首先就是收縮資料庫,主要對檔案進行收縮
2、重建索引

USE ufdata_112_2011; 

DECLARE @name varchar(100);

DECLARE authors_cursor CURSOR FOR  Select name   from sysobjects where xtype='u' order by id;

OPEN authors_cursor

FETCH NEXT FROM authors_cursor  INTO @name

WHILE @@FETCH_STATUS = 0 BEGIN    

DBCC DBREINDEX (@name,'',90)

FETCH NEXT FROM authors_cursor     INTO @name END

deallocate authors_cursor 

 

效果還是比較明顯的,47G的資料,縮小到6G多。