zoukankan      html  css  js  c++  java
  • 视图

    --视图:视图就是一个虚拟的表
    select *from view_1
    
    --显示所有学生的sno、sname、cno、degree
    select Student.Sno,sname,cno,degree from Student join Score on Student.Sno=Score.sno 
    --显示101学生的sno、sname、cno、degree
    select Student.Sno,sname,cno,degree from Student join Score on Student.Sno=Score.sno where Student.Sno=101
    
    create view view_2
    as
    select Student.Sno,sname,cno,degree from Student join Score on Student.Sno=Score.sno 
    go
    --视图,相当于起了一个别名 用于简便方法
    select*from view_2 where sno=101
    
    --子查询,将子查询查询出的结果集当做虚拟的临时表来使用
    select *from(select Student.Sno,sname,cno,degree from Student join Score on Student.Sno=Score.sno )as table2 where sno=101
    
    --分页查询
    --显示第三行第四行  ,后面not in屏蔽掉当前页的内容,前面top是取屏蔽之后的数据的一页显示条数,必须要用主键作为排除条件
    select top 2*from student where sno not in(select top 2 sno from student ) 
    
    --分页的存储过程
    create proc fenye
    @nowye int,--当前页
    @numbers int  --显示行数
    as
    --屏蔽数据,假设@nowye=1,@numbers=4 ,也就是说每1页有4条数据, 括号里面的是屏蔽的数据,若@nowye=1,@numbers=4,会屏蔽0条,也就是说会显示第一页的全部4条数据,以此类推
    select
    top (@numbers) *from student where sno not in(select top ((@nowye-1)*@numbers) sno from student ) go exec fenye 2,2 --创建万能分页 (未完善) create proc wannengfenye @nowye int,--当前页 @numbers int, --显示行数 @tablename varchar(50), @zhujian varchar(50) as select top (@numbers) *from @tablename where @zhujian not in(select top ((@nowye-1)*@numbers) @zhujian from @tablename) go exec fenye 2,2
  • 相关阅读:
    图书管理系统---基于form组件和modelform改造添加和编辑
    Keepalived和Heartbeat
    SCAN IP 解释
    Configure Active DataGuard and DG BROKER
    Oracle 11gR2
    我在管理工作中積累的九種最重要的領導力 (李開復)
    公募基金公司超融合基础架构与同城灾备建设实践
    Oracle 11g RAC for LINUX rhel 6.X silent install(静默安装)
    11gR2 静默安装RAC 集群和数据库软件
    Setting Up Oracle GoldenGate 12
  • 原文地址:https://www.cnblogs.com/lk-kk/p/4461287.html
Copyright © 2011-2022 走看看