我需要示例
在SQL Server中 FRAGMENTATION答案 0 :(得分:-1)
1.创建一个以GUID为主键的表格
2.do插入并检查碎片
3.重建检查碎片
你也可以像下面那样搜索更多SO示例
sql server碎片站点* .stackexchange.com
简单演示:
create table test1
(
id varchar(255) primary key default newid()
)
insert into test1
default values
go 100
--check fragmentation
select avg_fragmentation_in_percent, avg_fragment_size_in_pages, fragment_count, avg_page_space_used_in_percent
from sys.dm_db_index_physical_stats (DB_ID(), object_id('test1'), NULL, NULL, 'DETAILED')
--rebuild index
ALTER INDEX ALL ON test1
REBUILD
--check fragmentation
select avg_fragmentation_in_percent, avg_fragment_size_in_pages, fragment_count, avg_page_space_used_in_percent
from sys.dm_db_index_physical_stats (DB_ID(), object_id('test1'), NULL, NULL, 'DETAILED')