清除SQLServer数据库日志(SqlServer2005)
在主数据库文件进行大量的删除(新增,修改都会有日志),日志文件有1.5G。昨天还原数据库时初始值也才1MB。必须清除掉,不然太占空间了。上网找了个清除日志的方法。顺利将日志文件log.ldf从1.5G变为了1M。 我执行如下:
1.清空日志
DUMP TRANSACTION 库名 WITH NO_LOG
2.截断事务日志:
BACKUP LOG 数据库名 WITH NO_LOG
3.收缩数据库文件(如果不压缩,数据库的文件不会减小)
右键数据库->任务->收缩->数据库->确定
DBCC SHRINKDATABASE(数据库名)
4.将数据库设为自动收缩 右键数据库->属性->选项->自动->自动收缩设为True
相关文档:
/*drop table scourse
drop table course
drop table student
drop table major*/
create database db
use db
--专业表
create table major
(spno char(5) not null primary key,
spname varchar(20) not null,
pno char(2) )
--学生表
create table student
(sno char(7) not null primary key,
......
DATEDIFF(datepart, startdate, enddate)
Datepart Abbreviations
year yy, yyyy
quarter qq, q
month mm, m
......
继续SQLServer索引调优实践。这次探讨一下索引覆盖 - SQL Server主要使用索引去查询你需要的数据,当索引包括所有的你请求查询的字段,SQL Server将不需要去在表中查询。这个概念称做“索引覆盖”。
SQLServer2005的Non-clustered INDEX增加了一个“包含列(included column)
”选项。在 SQL Server 2 ......
sqlServer:
一次查询,数据库只返回一页的数据。而不是取出所有的数据。
pagesize: 每页显示记录数
cureentpage:当前页数
select * from ( select TOP pagesize * from ( SELECT TOP pagesize*cureentpage * from my_table ORDER BY id ASC ) as amyTable OR ......