SQL Server常用命令

发布时间 2023-10-27 11:01:06作者: 天笑

 --重建索引
dbcc dbreindex('表名','',90)

 

--清除数据库日志

use [数据库]

select FILE_ID,name,size,* from sys.database_files --查询数据库及日志名称
alter database [数据库名称] set recovery simple with no_wait
alter database [数据库名称] set recovery simple--简单模式,如果本身是简单模式不用执行

DBCC shrinkfile('日志名称',11,truncateonly)--清除数据

alter database [数据库名称] set recovery full with no_wait
alter database [数据库名称] set recovery full --还原为完全模式,如果本身是简单模式不用执行