반응형

[MSSQL] 트랜잭션 로그가 꽉 차서 해결할때. 로그 축소

 

DB서버가 용량 부족이라서 확인해보니 로그파일이 37기가!!!

 

바로 트랜잭션 축소 해버림. 

DBCC SHRINKFILE   
(  
    { file_name | file_id }   
    { [ , EMPTYFILE ]   
    | [ [ , target_size ] [ , { NOTRUNCATE | TRUNCATEONLY } ] ]  
    }  
)  
[ WITH NO_INFOMSGS ]  



--https://docs.microsoft.com/ko-kr/sql/t-sql/database-console-commands/dbcc-shrinkfile-transact-sql?view=sql-server-ver15
-- DB log 축소 
 
USE [DataBase];

ALTER DATABASE [DataBase] SET RECOVERY SIMPLE;

-- 로그파일을 10MB로 축소

DBCC SHRINKFILE ([DataBase_Log], 10);

ALTER DATABASE [DataBase] 
SET RECOVERY FULL;
-- 로그 파일을 지정한 대상 크기로 축소

USE AdventureWorks2012;  
GO  

-- Truncate the log by changing the database recovery model to SIMPLE.  
ALTER DATABASE AdventureWorks2012  
SET RECOVERY SIMPLE;  
GO  

-- Shrink the truncated log file to 1 MB.  
DBCC SHRINKFILE (AdventureWorks2012_Log, 1);  
GO  

-- Reset the database recovery model.  
ALTER DATABASE AdventureWorks2012  
SET RECOVERY FULL;  
GO  

 

https://docs.microsoft.com/ko-kr/sql/t-sql/database-console-commands/dbcc-shrinkfile-transact-sql?view=sql-server-ver15 

 

DBCC SHRINKFILE(Transact-SQL) - SQL Server

DBCC SHRINKFILE(Transact-SQL)

docs.microsoft.com

 

반응형

+ Recent posts