索引.sql
来自「简单的sql语句 数据与汇总。 高手多多指点。」· SQL 代码 · 共 72 行
SQL
72 行
use northwind
go
select * from employees
go
create nonclustered index cl_lastname
on employees(lastname)
go
drop index employees.cl_lastname
go
select * from customers
go
sp_help customers
go
create unique nonclustered index u_companyname
on customers(companyname)
go
select customerid,count(customerid) as '# of duplicates'
from customers
group by customerid
having count(customerid)>1
order by customerid
go
create unique nonclustered index u_ordid_proid
on [order details](orderid,productid)
go
exec sp_help [order details]
go
exec sp_helpindex [order details]
go
exec sp_configure
go
create index orderid_ind
on orders(orderid)
with pad_index,fillfactor=70
go
dbcc showcontig(customers,pk_customers)
go
exec sp_help customers
go
dbcc dbreindex('customers',pk_customers,80)
dbcc dbreindex('customers','',80)
go
/*
上例使用填充因子值80 重建 customers 表上的所有索引。
*/
dbcc indexdefrag(northwind,customers,pk_customers)
go
create unique nonclustered index u_ordid_proid
on [order details](orderid,productid)
with drop_existing,fillfactor=65
go
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?