zoukankan      html  css  js  c++  java
  • 常用SQL语句

    1.查询所有表的数据量
      
     SELECT A.NAME ,B.ROWS  FROM sysobjects  A JOIN sysindexes B
     ON A.id = B.id WHERE A.xtype = 'U' AND B.indid IN(0,1) 
     ORDER BY B.ROWS DESC
     
    2.清理数据库日志
    USE [master]
    
    GO
    ALTER DATABASE TEST SET RECOVERY SIMPLE WITH NO_WAIT
    GO
    ALTER DATABASE TEST SET RECOVERY SIMPLE
    GO
    USE SHSDBarCode 
    
    GO
    DBCC SHRINKFILE (N'TEST _log' , 2048,TRUNCATEONLY)
    GO
    USE [master]
    GO
    ALTER DATABASE TEST  SET RECOVERY FULL WITH NO_WAIT
    GO
    ALTER DATABASE TEST  SET RECOVERY FULL
    GO
    3.查询包含的数据文本
    select * 
    from sysobjects o, syscomments s 
    where o.id = s.id 
    and text like '%Spend%' 
    and o.xtype = 'P'
    4.查询数据库操作
      
    SELECT 
           ST.text AS '执行的SQL语句',
           QS.creation_time AS '执行时间' ,  
           QS.*
    FROM   sys.dm_exec_query_stats QS
           CROSS APPLY 
    sys.dm_exec_sql_text(QS.sql_handle) ST
    WHERE  QS.creation_time BETWEEN '2020-07-08 00:00:00' AND '2020-07-08 08:59:59' 
    and st.text like '%TEST1%'
    ORDER BY
         QS.total_elapsed_time DESC
  • 相关阅读:
    触发器和存储过程简述
    sql笔记
    AES加密解密代码
    动态获取实体类及类中方法
    springboot metrics elk
    深入浅出Spring Security
    RandomValueStringGenerator
    ExceptionUtils
    spring.main.web-application-type: none
    excel前80%平均分
  • 原文地址:https://www.cnblogs.com/alannxu/p/13453014.html
Copyright © 2011-2022 走看看