一:在较小的结果集上上操作 1.仅返回需要的列 2.分页获取数据 EF实现分页: public object getcp(int skiprows,int currentpagerows) { HRUser dbcontext = new HRUser(); var cps = dbcontext.Product.Join(dbcontext.ProductCategory, a => a.ProductSubcategoryKey, ar => ar.ProductCategoryKey,…
1,在什么列适合添加索引 (1)较频繁的作为查询条件字段应该添加索引 select * from emp where empid = 2; (2)唯一性太差的字段不适合添加索引,即时频繁作为查询条件. select * from emp where sex = '男'; (3)更新非常频繁的字段不适合创建索引. select * from emp where logincount = 2; (4)不会出现在where条件中的字段,不应该创建索引. 2,索引的种类 (1)主键索引,把某列设为主键,…
--1. 使用IN关键字 --例1 查询系别人数不足5人的系别中学生的学号.姓名和系别 --系别人数不足5人的系别 ==>选择条件 select Sdept from Student Group by Sdept --显示这些系别的学生信息 Select sno, sname, sdept From Student WHERE sdept IN ( select Sdept from Student Group by Sdept ) --2. 使用EXISTS关键字 --例2 如果“MA"…