自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

SQL Server數(shù)據(jù)庫日志清除

數(shù)據(jù)庫 SQL Server
SQL Server數(shù)據(jù)庫的操作可能會產生一些沒用的日志文件,在數(shù)據(jù)庫中也是占內存,沒什么用,這時就要將那些沒用的日志給清除掉,以保證SQL Server數(shù)據(jù)庫有更大容量,可以儲存更過有用的數(shù)據(jù)。

SQL Server數(shù)據(jù)庫日志清除的兩個方法:

方法一

一般情況下,SQL數(shù)據(jù)庫的收縮并不能很大程度上減小數(shù)據(jù)庫大小,其主要作用是收縮日志大小,應當定期進行此操作以免數(shù)據(jù)庫日志過大。

1、設置數(shù)據(jù)庫模式為簡單模式:打開SQL企業(yè)管理器,在控制臺根目錄中依次點開microsoft SQL Server-->SQL Server組-->雙擊打開你的服務器-->雙擊打開數(shù)據(jù)庫目錄-->選擇你的數(shù)據(jù)庫名稱(如論壇數(shù)據(jù)庫forum)-->然后點擊右鍵選擇屬性-->選擇選項-->在故障還原的模式中選擇“簡單”,然后按確定保存。

2、在當前數(shù)據(jù)庫上點右鍵,看所有任務中的收縮數(shù)據(jù)庫,一般里面的默認設置不用調整,直接點確定

3、收縮數(shù)據(jù)庫完成后,建議將您的數(shù)據(jù)庫屬性重新設置為標準模式,操作方法同***點,因為日志在一些異常情況下往往是恢復數(shù)據(jù)庫的重要依據(jù)。

方法二

以下為引用的內容:

set nocount on
declare @logicalfilename sysname,
@maxminutes int,
@newsize int

use tablename
-- 要操作的數(shù)據(jù)庫名
select @logicalfilename = 'tablename_log',
-- 日志文件名
@maxminutes = 10,
-- limit on time allowed to wrap log.
@newsize = 1
-- 你想設定的日志文件的大小(m)

-- setup / initialize
declare @originalsize int
select @originalsize = size
from sysfiles
where name = @logicalfilename
select 'original size of ' + db_name() + ' log is ' +
convert(varchar(30),@originalsize) + ' 8k pages or ' +
convert(varchar(30),(@originalsize*8/1024)) + 'mb'
from sysfiles
where name = @logicalfilename
create table dummytrans
(dummycolumn char (8000) not null)

declare @counter int,
@starttime datetime,
@trunclog varchar(255)
select @starttime = getdate(),
@trunclog = 'backup log '
+ db_name() + ' with truncate_only'

dbcc shrinkfile (@logicalfilename, @newsize)
exec (@trunclog)
-- wrap the log if necessary.
while @maxminutes > datediff
(mi, @starttime, getdate()) -- time has not expired
and @originalsize =
(select size from sysfiles where name = @logicalfilename)
and (@originalsize * 8 /1024) > @newsize
begin -- outer loop.
select @counter = 0
while ((@counter < @originalsize / 16) and (@counter < 50000))
begin -- update
insert dummytrans values ('fill log')
delete dummytrans
select @counter = @counter + 1
end
exec (@trunclog)
end
select 'final size of ' + db_name() + ' log is ' +
convert(varchar(30),size) + ' 8k pages or ' +
convert(varchar(30),(size*8/1024)) + 'mb'
from sysfiles
where name = @logicalfilename
drop table dummytrans
set nocount off
 

上文介紹了SQL Server數(shù)據(jù)庫日志清除的兩種方法,如果大家有更多的好方法,歡迎那出來與我們一起分享。

【編輯推薦】

  1. SQL Server無日志恢復數(shù)據(jù)庫(一)
  2. SQL Server無日志恢復數(shù)據(jù)庫(二)
  3. SQL Server Compact Edition啟用日志記錄
  4. 刪除SQL Server大容量日志的方法

 

責任編輯:迎迎 來源: 賽迪網
相關推薦

2024-04-02 08:21:45

數(shù)據(jù)庫日志SQL

2010-07-15 17:28:50

SQL Server

2011-08-09 17:24:21

SQL Server 數(shù)據(jù)庫日志

2011-04-01 09:17:36

SQL Server數(shù)據(jù)庫

2011-04-01 09:31:01

SQL Server數(shù)據(jù)庫

2024-09-29 16:11:55

NLogSQL數(shù)據(jù)庫

2010-07-07 16:46:52

SQL Server日

2010-07-08 11:05:14

SQL Server數(shù)

2010-07-08 13:13:14

清除SQL Serve

2021-05-17 06:57:34

SQLServer數(shù)據(jù)庫

2011-07-15 15:55:50

SQL Server日附加數(shù)據(jù)庫

2010-09-02 11:56:21

SQL刪除

2010-07-01 12:44:52

SQL Server數(shù)

2010-06-28 09:43:05

SQL Server數(shù)

2009-03-19 09:44:07

SQL Server數(shù)據(jù)庫遷移數(shù)據(jù)庫

2010-06-30 11:16:50

SQL Server

2011-04-29 14:30:23

2011-03-24 09:45:34

SQL Server數(shù)恢復

2011-03-24 09:07:11

SQL Server數(shù)備份

2011-03-24 09:24:08

SQL Server數(shù)還原
點贊
收藏

51CTO技術棧公眾號