查看数据库表占用的磁盘空间 ,执行存储过程 exec sp_spaceused tableName
创建聚簇索引
create clustered index indexName on tableName(columnName) (不允许有重复记录)
create index clustered index indexName on tableName(columnName) with allow_dup_row (允许有重复记录)
dup 复制品;重复
cluster 聚集
distinct 明显的,独特的
-------遍历数据库所有表
declare @tableName varchar(30)
declare @truncateSql varchar(255)
declare Truncate_Cursor cursor for
select [name] from sysobjects where type='u'
open Truncate_Cursor
fetch Truncate_Cursor into
@tableName
while(@@fetch_status=0)
begin
set @truncateSql='truncate table :'+@tableName
print @truncateSql
fetch Truncate_Cursor into @tableName
end
close Truncate_Cursor
deallocate Truncate_Cursor
-------清空数据库
exec sp_MSforeachtable "truncate table ?"