• 索引 视图 游标


    索引:

    不用扫描整个表就实现对数据快速访问的途径。

    二进制类型不支持索引

    视图:

    从一个或多个基本表中导出所显示的表,是没有数据的虚表。

    多表出一视图,一表出多视图,多表与一视图出一视图

    游标:

    所有数据库:行的次序无关,列的次序无关

    select Code,Name,Brand_Name,Prod_Name,oil,Price from car

        join Brand on Car.Brand = Brand.Brand_Code

        join Productor on Productor.Prod_Code = Brand.Prod_Code

       

    select * from viewcar

     

    select * from chinastates where parentareacode='37'

     

    create view ShanDong

    as

    select * from chinastates where parentareacode='37'

    go

     

    select * from shandong

     

    insert into shandong(areacode,areaname,parentareacode,root,zone) values('3779','临淄','38','','')

     

    select * from viewcar

    insert into viewcar values('c222','鲁轻电动汽车','超强续行王','山东轻骑','0','5')

     

    declare cur_car cursor scroll

    for select name from Car where Name like '奥迪%'

    open cur_car

    fetch first from cur_car

    while @@FETCH_STATUS = 0

    begin

        declare @name varchar(50)

        fetch next  from cur_car into @name

        --print @name

       

        if ltrim(left(@name,LEN('奥迪A4 07款')))='奥迪A4 07款'

        begin

           fetch prior from cur_car into @name

           print @name

           fetch relative 2 from cur_car into @name

           print @name

        end

       

    end

    close cur_car

    deallocate cur_car

  • 相关阅读:
    Servlet基本概念及其部署
    MSSQL数据库全库批量替换
    我的第一个GAE(google appengine)应用
    今天你有病了吗?
    [Microsoft][ODBC SQL Server Driver][DBNETLIB] 一般性网络错误
    Google appengine 上传输错用户名解决办法;
    查看畸形文件
    Session
    jq幻灯片2
    JS打开层/关闭层/移动层动画效果
  • 原文地址:https://www.cnblogs.com/wanwuguizong/p/3977531.html
Copyright © 2020-2023  润新知