• CLOUD清理临时表空间


    --查找空间名、物理空间路径

    SELECT name, physical_name
    FROM sys.master_files
    WHERE database_id = DB_ID('tempdb');


    可以执行以下脚本批量执行
    ---临时表数量查询
    select COUNT(1) from sys.tables u
    join T_BAS_TEMPORARYTABLENAME v on u.name=v.FTABLENAME and
    ( v.FPROCESSTYPE=1 or v.FCREATEDATE<GETDATE()-1)

    --删除(一次性全部删除可能会花很长时间,建议分批删除,top 1000 表示该批删除1000个表)
    declare @sql as varchar(max)
    set @sql=''
    select @sql=@sql+'drop table '+name+';' from
    (select top 1000 name from sys.tables u
    join T_BAS_TEMPORARYTABLENAME v on u.name=v.FTABLENAME and
    ( v.FPROCESSTYPE=1 or v.FCREATEDATE<GETDATE()-1)) T;
    exec(@sql);
    delete u from T_BAS_TEMPORARYTABLENAME u where
    not exists(select 1 from sys.tables where u.ftablename=name );
    临时表删除后收缩账套以释放空间。

  • 相关阅读:
    hero
    今年暑假不AC
    Who's in the Middle
    A Simple Problem with Integers
    I hate it
    敌兵布阵
    Ordering Tasks
    Points on Cycle
    食物链
    c++ 14.0下载地址
  • 原文地址:https://www.cnblogs.com/RogerLu/p/10598003.html
Copyright © 2020-2023  润新知