zoukankan      html  css  js  c++  java
  • SQL Server Temp Table

    临时表与永久表相似,但临时表存储在 tempdb 中,当不再使用时会自动删除。

    临时表有两种类型:本地和全局。它们在名称、可见性以及可用性上有区别。本地临时表的名称以单个数字符号 (#) 打头;它们仅对当前的用户连接是可见的;当用户从 SQL Server 实例断开连接时被删除。全局临时表的名称以两个数字符号 (##) 打头,创建后对任何用户都是可见的,当所有引用该表的用户从 SQL Server 断开连接时被删除。

    例如,如果创建了 employees 表,则任何在数据库中有使用该表的安全权限的用户都可以使用该表,除非已将其删除。如果数据库会话创建了本地临时表 #employees,则仅会话可以使用该表,会话断开连接后就将该表删除。如果创建了 ##employees 全局临时表,则数据库中的任何用户均可使用该表。如果该表在您创建后没有其他用户使用,则当您断开连接时该表删除。如果您创建该表后另一个用户在使用该表,则 SQL Server 将在您断开连接并且所有其他会话不再使用该表时将其删除。
    'conn.execute("if object_id('tempdb..##temp_a') is not null drop table ##temp_a")
    'conn.execute("if object_id('tempdb..##temp_b') is not null drop table ##temp_b")

      '驗測是否在temp表
      sql="select isnull(OBJECT_ID('tempdb..#Temp_material'),0) as temp,"&_
          "isnull(OBJECT_ID('tempdb..##Temp_material_A'),0) as temp_A,"&_
          "isnull(OBJECT_ID('tempdb..##Temp_material_B'),0) as temp_B"
      set rs=conn.execute(sql)
      if (rs(0)<>0 or rs(1)<>0 or rs(2)<>0) then
        msg="系統正忙,請過段時間再查詢."
        response.Write("<script language='javascript'>alert('"&msg&"');</script>")
        rs.close
        conn.close
        response.end()
      end if

    申明

    非源创博文中的内容均收集自网上,若有侵权之处,请及时联络,我会在第一时间内删除.再次说声抱歉!!!

    博文欢迎转载,但请给出原文连接。

  • 相关阅读:
    SpringBoot入门篇--整合mybatis+generator自动生成代码+druid连接池+PageHelper分页插件+SpringBoot整合Mybatis-plus
    认证 (authentication) 和授权 (authorization) 的区别
    新手redis集群搭建
    Nginx是什么?
    分布式和集群的区别
    springBoot 项目 jar/war打包 并运行
    pyV8不支持dom操作,关于PyV8的支持DOM的疑问
    Python爬虫:更加优雅的执行JavaScript(PyV8)
    python中正则表达式 re.findall 用法
    Python爬虫-破解JS加密的Cookie
  • 原文地址:https://www.cnblogs.com/Athrun/p/763510.html
Copyright © 2011-2022 走看看