解决方法: 方法 1.sp_spaceused 方法 2.dbcc sqlperf 方法 3.dbcc showfilestats 方法 4.dbcc showcontig 方法 5.sys.dm_db_partiton_stats -------------------------------------------------------------------------------------------------------------------------------------…
方法 1. sys.dm_db_file_space_usage. 方法 2. sys.dm_db_session_space_usage. -------------------------------------------------------------------------------------------------------------------------------------------------------------- 方法 1 . sys_dm_db_fil…
方法 1. restore labelonly 方法 2. restore headeronly 方法 3. restore filelistonly 方法 4. restore verifyonly -----------------------------------------------------------------------------------------------------------------------------------------------------…
SQL Server遍历表一般都要用到游标,SQL Server中可以很容易的用游标实现循环,实现SQL Server遍历表中记录.本文将介绍利用使用表变量和游标实现数据库中表的遍历. 表变量来实现表的遍历 以下代码中,代码块之间的差异已经用灰色的背景标记. DECLARE @temp TABLE ( , ) , ) ) DECLARE @tempId INT , ) INSERT INTO @temp VALUES ( 'a' ) INSERT INTO @temp VALUES ( 'b'…
GO /****** Object: StoredProcedure [dbo].[SpaceUsed] Script Date: 2017-12-01 11:15:11 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO create procedure [dbo].[sqlTool_SpaceUsed] as begin declare @id int -- The object id of @objname. ) -- The…
使用超级管理员账户登录,并执行以下命令: SELECT * FROM [Master].[dbo].[SYSPROCESSES] WHERE [DBID] IN ( SELECT [DBID] FROM [Master].[dbo].[SYSDATABASES] WHERE ) ,) = '09 2 2014 ' order by last_batch,hostname…
方法 1. sp_configure; execute sp_configure; 方法 2. sys.configurations select * from sys.configurations          order by name;          go…
SELECT DISTINCT DB_NAME() AS N'db_name' , E.name AS N'schema_name' , OBJECT_NAME(a.object_id) AS N'table_name' , b.name N'index_name' , user_seeks N'seek' , user_scans N'scan' , last_user_seek , last_user_scan , rows FROM sys.dm_db_index_usage_stats…
mysql系统变量分为全局变量和会话变量,全局变量的修改影响到整个服务器,会话变量修改只影响当前的会话. 查看log日志是否开启 show variables like 'general_log' set GLOBAL general_log='ON'; SET GLOBAL general_log_file = '/tmp/mysql.log' 不使用的时候记得关掉,否则会大量占用磁盘空间. show processlist命令查看了当前正在执行的sql语句,同时可以查看用户的当前连接 查看慢…
http://www.hanyu123.cn/html/c61/6790.html 一.查某一列(或多列)的重复值.(只可以查出重复记录的值,不能查出整个记录的信息) 例如:查找stuid,stuname重复的记录: select stuid,stuname from stuinfo group by stuid,stuname having(count(*))>1 二.查某一列有重复值的记录.(此方法查出的是所有重复的记录,如果有两条记录重复的,就查出两条) 例如:查找stuid重复的记录:…