sql server数据库惯用语句

sql server数据库常用语句

1、创建索引的语句

create index 索引名 on 表(字段1,字段2,、、、);

create index index_AttachFile on AttachFile(CBillGuid,CGuid,DCreateTime);

 

2、查询表有哪些索引

select b.*  from sys.sysobjects a, sys.sysindexes b where a.id = b.id  and a.name = 表名 and b.rows <>0;

 

3、常用的系统表

sys.indexes 索引
sys.objects 对象(表...)
sys.columns 字段
sys.index_columns 索引_字段
sys.tables 自定义表